self.get_orders

lumibot.strategies.strategy.Strategy.get_orders(self, identifiers: list[str] = None, statuses=None, broker_refresh: bool = True, broker_refresh_ttl_seconds: float = 0.0, *, max_age: float | None = None)

Get tracked orders, optionally filtered by identifiers and OrderStatus values.

In live trading this refreshes broker order state before returning by default. For currently active/open orders, use statuses=Order.ACTIVE_STATUSES or the string “open”. Status strings are accepted case-insensitively: “open”, “active” and “working” mean every still-working order (same as Order.ACTIVE_STATUSES); any OrderStatus value or name (“filled”, “fill”, “canceled”, “partial_fill”, “error”) and common broker spellings (“cancelled”, “partially_filled”, “rejected”) match that status. Unknown strings raise ValueError listing the valid ones.

If you need to verify the exact order immediately after submit_order(order), prefer self.get_order(order.identifier). Broad broker order-list endpoints used by get_orders(…) can lag briefly after submit; if broad-list logic must run immediately after submit, use a short self.sleep(…, process_pending_orders=True) first.

Parameters:
  • identifiers (list of str) – A list of order identifiers to filter the orders by. If None, returns all tracked orders for the strategy.

  • statuses (Order.OrderStatus, str, or iterable of those) – Optional status filter. Use Order.ACTIVE_STATUSES or “open” for currently active orders.

  • max_age (float, optional) – 0 always reads the broker (no shortcut). A positive value accepts a broker read up to that many seconds old. With None (default) a live broker that supports it (Schwab) may answer from its last good order-list read when this strategy has no open, unknown or recently ended order and no order activity since that read; that read is never older than LUMIBOT_IDLE_SYNC_MAX_AGE seconds (default 30). A small max_age means more broker reads.

Returns:

Order objects for the strategy if there are tracked

Return type:

list of Order objects

Example

>>> # Get all tracked orders
>>> orders = self.get_orders()
>>> for order in orders:
>>>     # Show the status of each order
>>>     self.log_message(order.status)
>>> # Get active/open orders
>>> orders = self.get_orders(statuses=Order.ACTIVE_STATUSES)
>>> for order in orders:
>>>     self.cancel_order(order)