self.get_order¶
- lumibot.strategies.strategy.Strategy.get_order(self, identifier: str, broker_refresh: bool = True, broker_refresh_ttl_seconds: float = 0.0, *, max_age: float | None = None)
Get a tracked order given an identifier. Check the details of the order including status, etc.
In live trading this refreshes broker order state before returning by default. Refresh normally reads the broker order list; a tracked active order absent from that list may also receive a direct lookup. This is not an unconditional single-order HTTP request. Set broker_refresh=False to read only tracked state. An order this strategy already knows is completely filled is final, so it is returned without asking the broker again.
max_age=0always asks the broker (no shortcut); a positivemax_ageaccepts a broker read up to that many seconds old; a smallmax_agemeans more broker reads.order.status_updated_at,order.status_checked_atandorder.status_sourcesay when the status last changed, when a broker read last confirmed it, and where it came from (Schwab sets the source; other brokers leave itNone).- Returns:
An order objects for the identifier
- Return type:
Order or None
Example
>>> # Get the order object for the order id >>> order = self.get_order(order_id) >>> # Show the status of the order >>> self.log_message(order.status)