nautechsystems/nautilus_trader · error

Order not found in cache

Error message

Order {client_order_id} not found in cache

What it means

Lookup failure inside the matching engine: an order referenced by client_order_id is no longer present in the cache (e.g. purged after closure or evicted), so the engine cannot continue processing for it.

Solutions

  1. Verify the order was not already closed and purged from the cache
  2. Re-add or re-query the order before retrying the operation that referenced it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/execution/src/matching_engine/mod.rs:5234 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/1f5b7dae634f497a. Report an issue: GitHub.

Appendix: source

Thrown at crates/execution/src/matching_engine/mod.rs:5234

            self.remove_queue_position(order.client_order_id());

            // MarketToLimit reads `cached_filled_qty` in its caller to compute leaves;
            // its own cleanup happens there after the read.
            if order.order_type() != OrderType::MarketToLimit {
                self.purge_cached_filled_qty_if_closed(order.client_order_id());
            }
        }

        if self.config.support_contingent_orders
            && let Some(contingency_type) = order.contingency_type()
        {
            match contingency_type {
                ContingencyType::Oto => {
                    if let Some(linked_orders_ids) = order.linked_order_ids() {
                        for client_order_id in linked_orders_ids {
                            let mut child_order = match self.order_snapshot(*client_order_id) {
                                Some(child_order) => child_order,
                                None => anyhow::bail!("Order {client_order_id} not found in cache"),
                            };

                            if child_order.is_closed() || child_order.is_active_local() {
                                continue;
                            }

                            // Check if we need to index position id
                            if let (None, Some(position_id)) =
                                (child_order.position_id(), order.position_id())
                            {
                                self.cache
                                    .borrow_mut()
                                    .add_position_id(
                                        &position_id,
                                        &self.venue,
                                        client_order_id,
                                        &child_order.strategy_id(),
                                    )

View on GitHub (pinned to 18893faf8b)