Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# self.submit_orders

strategies.strategy.Strategy.submit_orders(self, orders)

  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.

  Returns:

    List of processed order object.

  Return type:

    list of orders

  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
      >>> asset = Asset(
          symbol="EUR",
          currency="USD",
          asset_type="forex",
      )
      >>> order1 = self.create_order(asset, 100, "buy")
      >>> order2 = self.create_order(asset, 200, "buy")
      >>> self.submit_orders([order1, order2])

      >>> # For 2 FOREX sell orders
      >>> asset = Asset(
          symbol="EUR",
          currency="USD",
          asset_type="forex",
      )
      >>> order1 = self.create_order(asset, 100, "sell")
      >>> order2 = self.create_order(asset, 200, "sell")
      >>> self.submit_orders([order1, order2])

      >>> # For 2 CRYPTO buy orders.
      >>> asset_BTC = Asset(
      >>>    "BTC",
      >>>    asset_type="crypto",
      >>> )
      >>> asset_ETH = Asset(
      >>>    "ETH",
      >>>    asset_type="crypto",
      >>> )
      >>> asset_quote = Asset(
      >>>    "USD",
      >>>    asset_type="crypto",
      >>> )
      >>> 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])