self.wait_for_order_execution¶
- lumibot.strategies.strategy.Strategy.wait_for_order_execution(self, order: Order)
Wait for one specific order to be executed or canceled by the broker
In a backtest this returns at once: simulated time cannot move while the iteration waits, so the order fills when the backtest processes orders after the iteration. Read its status on the next iteration or in
on_filled_order. A cancel is confirmed immediately in a backtest.- Parameters:
order (Order object) – Order object to be executed by the broker.
- Return type:
Order object
Example
>>> # For a market buy order >>> order = self.create_order("SPY", 100, "buy") >>> self.submit_order(order) >>> self.wait_for_order_execution(order)