Trading
BuyLongCommand
Places a long buy order for a specified quantity of a ticker on a given trade date.
Constructor Parameters:
ticker (str)
: The ticker symbol for the asset to be bought.quantity (int)
: The number of units to be purchased.trade_date (str)
: The date on which the trade is executed.
Methods:
execute(self, data_provider, simulation)
: Retrieves the current price fromdata_provider
and executes a buy order using thesimulation
object. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action
,type
,ticker
,quantity
, andprice
.
Example Usage:
SellLongCommand
Places a long sell order for a specified quantity of a ticker on a given trade date.
Constructor Parameters:
ticker (str)
: The ticker symbol for the asset to be sold.quantity (int)
: The number of units to be sold.trade_date (str)
: The date on which the trade is executed.
Methods:
execute(self, data_provider, simulation)
: Retrieves the current price fromdata_provider
and executes a sell order using thesimulation
object. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action
,type
,ticker
,quantity
, andprice
.
Example Usage:
SellShort
Places a short buy order (to close a short position) for a specified quantity of a ticker on a given trade date.
Constructor Parameters:
ticker (str)
: The ticker symbol for the asset to be bought.quantity (int)
: The number of units to be purchased.trade_date (str)
: The date on which the trade is executed.
Methods:
execute(self, data_provider, simulation)
: Retrieves the current price fromdata_provider
and executes a buy order using thesimulation
object. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action
,type
,ticker
,quantity
, andprice
.
Example Usage:
CoverShort
Places a short sell order for a specified quantity of a ticker on a given trade date.
Constructor Parameters:
ticker (str)
: The ticker symbol for the asset to be sold.quantity (int)
: The number of units to be sold.trade_date (str)
: The date on which the trade is executed.
Methods:
execute(self, data_provider, simulation)
: Retrieves the current price fromdata_provider
and executes a sell order using thesimulation
object. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action
,type
,ticker
,quantity
, andprice
.
Example Usage:
Last updated