💳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_providerand executes a buy order using thesimulationobject. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action,type,ticker,quantity, andprice.
Example Usage:
buy_command = BuyLongCommand(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = buy_command.execute(data_provider, simulation)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_providerand executes a sell order using thesimulationobject. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action,type,ticker,quantity, andprice.
Example Usage:
sell_command = SellLongCommand(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = sell_command.execute(data_provider, simulation)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_providerand executes a buy order using thesimulationobject. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action,type,ticker,quantity, andprice.
Example Usage:
sell_short_command = SellShort(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = sell_short_command.execute(data_provider, simulation)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_providerand executes a sell order using thesimulationobject. Returns a dictionary containing the details of the trade.
Returns: A dictionary with keys
action,type,ticker,quantity, andprice.
Example Usage:
cover_short_command = CoverShort(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = cover_short_command.execute(data_provider, simulation)Last updated