Broker API

class quotek::broker

broker class is meant to embedd all the methods that interract with the broker configured by the user.

Public Functions

broker(strategy *s)

Broker object constructor

Return
new broker object.
Parameters
  • strategy -

    back link to parent strategy object

void buy(std::string asset, int quantity, int stop, int limit)

buy sends a buy order to the broker. it will then open a long position having the caracteristics defined in the arguments.

Parameters
  • asset -

    name of the asset to take position on.

  • quantity -

    Number of contracts to take for the position.

  • stop -

    Stop-loss security thereshold, in BPS.

  • limit -

    Profit thereshold before close, in BPS.

void buy_hedged(std::string asset, std::string hedged_asset, int quantity, int stop, int limit)

buy_hedged sends a buy order to the broker along with a sell order for the another asset. quantity, stop and limits are the same for the long position and the hedged one.

Parameters
  • asset -

    name of the asset to take position on.

  • hedged_asset -

    name of the asset to take position on for hedging.

  • quantity -

    Number of contracts to take for the position.

  • stop -

    Stop-loss security thereshold, in BPS.

  • limit -

    Profit thereshold before close, in BPS.

void buy_hedged_asym(std::string asset, int quantity, int stop, int limit, std::string hedged_asset, int hedged_quantity, int hedged_stop, int hedged_limit)

same than buy_hedged but here you can choose the quantity, stop and limit for hedged asset.

void sell(std::string asset, int quantity, int stop, int limit)

sell sends a sell order to the broker. It will then open a short position having the caracteristics defined in the arguments.

Parameters
  • asset -

    name of the asset to take position on.

  • quantity -

    Number of contracts to take for the position.

  • stop -

    Stop-loss security thereshold, in BPS.

  • limit -

    Profit thereshold before close, in BPS.

void smartbuy(std::string asset, int expexted_risk_reward)

smartbuy will place a long trade where stop and limit will be automatically computed according to:

  • a risk reward ratio provided by the user
  • money management rules defined in the configuration

void smartsell(std::string asset, int expexted_risk_reward)

smartsell will place a short trade where stop and limit will be automatically computed according to:

  • a risk reward ratio provided by the user.
  • money management rules defined in the configuration.

void close_position(std::string ticket_id)

close_position allows to close a position given its ticket id given by the broker.

Parameters
  • ticket_id -

    id of the position ticket provided by the broker.