self.submit_orders#
- lumibot.strategies.strategy.Strategy.submit_orders(self, orders, **kwargs)#
Submit a list of orders
Submits a list of orders for processing by the active broker.
- Parameters:
orders (list of orders) – A list of order objects containing the asset and instructions for the orders.
is_multileg (bool) – Tradier only. A boolean value to indicate if the orders are part of one multileg order. Currently this is only available for Tradier.
order_type (str) – Tradier only. The order type for the multileg order. Possible values are: (‘market’, ‘debit’, ‘credit’, ‘even’). Default is ‘market’.
duration (str) – Tradier only. The duration for the multileg order. Possible values are: (‘day’, ‘gtc’, ‘pre’, ‘post’). Default is ‘day’.
price (float) – Tradier only. The limit price for the multileg order. Required for ‘debit’ and ‘credit’ order types.
tag (str) – Tradier only. A tag for the multileg order.
- Returns:
List of processed order objects.
- Return type:
list of Order objects
Example
>>> # For 2 market buy orders >>> order1 = self.create_order("SPY", 100, "buy") >>> order2 = self.create_order("TLT", 200, "buy") >>> self.submit_orders([order1, order2])
>>> # For 2 limit buy orders >>> order1 = self.create_order("SPY", 100, "buy", limit_price=100.00) >>> order2 = self.create_order("TLT", 200, "buy", limit_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 stop loss orders >>> order1 = self.create_order("SPY", 100, "buy", stop_price=100.00) >>> order2 = self.create_order("TLT", 200, "buy", stop_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 stop limit orders >>> order1 = self.create_order("SPY", 100, "buy", limit_price=100.00, stop_price=100.00) >>> order2 = self.create_order("TLT", 200, "buy", limit_price=100.00, stop_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 market sell orders >>> order1 = self.create_order("SPY", 100, "sell") >>> order2 = self.create_order("TLT", 200, "sell") >>> self.submit_orders([order1, order2])
>>> # For 2 limit sell orders >>> order1 = self.create_order("SPY", 100, "sell", limit_price=100.00) >>> order2 = self.create_order("TLT", 200, "sell", limit_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 stop loss orders >>> order1 = self.create_order("SPY", 100, "sell", stop_price=100.00) >>> order2 = self.create_order("TLT", 200, "sell", stop_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 stop limit orders >>> order1 = self.create_order("SPY", 100, "sell", limit_price=100.00, stop_price=100.00) >>> order2 = self.create_order("TLT", 200, "sell", limit_price=100.00, stop_price=100.00) >>> self.submit_orders([order1, order2])
>>> # For 2 FOREX buy orders >>> from lumibot.entities import Asset >>> >>> base_asset = Asset( symbol="EUR", asset_type=Asset.AssetType.FOREX, ) >>> quote_asset = Asset( symbol="USD", asset_type=Asset.AssetType.FOREX, ) >>> order1 = self.create_order(base_asset, 100, "buy", quote=quote_asset) >>> order2 = self.create_order(base_asset, 200, "buy", quote=quote_asset) >>> self.submit_orders([order1, order2])
>>> # For 2 FOREX sell orders >>> from lumibot.entities import Asset >>> >>> base_asset = Asset( symbol="EUR", asset_type=Asset.AssetType.FOREX, ) >>> quote_asset = Asset( symbol="USD", asset_type=Asset.AssetType.FOREX, ) >>> order1 = self.create_order(base_asset, 100, "sell", quote=quote_asset) >>> order2 = self.create_order(base_asset, 200, "sell", quote=quote_asset) >>> self.submit_orders([order1, order2])
>>> # For 2 CRYPTO buy orders. >>> from lumibot.entities import Asset >>> >>> asset_BTC = Asset( >>> "BTC", >>> asset_type=Asset.AssetType.CRYPTO, >>> ) >>> asset_ETH = Asset( >>> "ETH", >>> asset_type=Asset.AssetType.CRYPTO, >>> ) >>> asset_quote = Asset( >>> "USD", >>> asset_type=Aset.AssetType.FOREX, >>> ) >>> order1 = self.create_order(asset_BTC, 0.1, "buy", quote=asset_quote) >>> order2 = self.create_order(asset_ETH, 10, "buy", quote=asset_quote) >>> self.submit_order([order1, order2]) >>> or... >>> order1 = self.create_order((asset_BTC, asset_quote), 0.1, "buy") >>> order2 = self.create_order((asset_ETH, asset_quote), 10, "buy") >>> self.submit_order([order1, order2])