{"record":{"id":"a1c37c3f9f360a34","repo":"nautechsystems/nautilus_trader","slug":"matching-engine-not-found-for-instrument-instrume","errorCode":null,"errorMessage":"Matching engine not found for instrument {instrument_id}","messagePattern":"Matching engine not found for instrument (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/backtest/src/exchange.rs","lineNumber":1922,"sourceCode":"                TradingCommand::ModifyOrder(ref command) => {\n                    matching_engine.process_modify(command, account_id);\n                }\n                TradingCommand::ModifyOrders(ref command) => {\n                    matching_engine.process_batch_modify(command, account_id);\n                }\n                TradingCommand::CancelOrder(ref command) => {\n                    matching_engine.process_cancel(command, account_id);\n                }\n                TradingCommand::CancelOrders(ref command) => {\n                    matching_engine.process_batch_cancel(command, account_id);\n                }\n                TradingCommand::CancelAllOrders(ref command) => {\n                    matching_engine.process_cancel_all(command, account_id);\n                }\n                _ => {}\n            }\n        } else {\n            panic!(\"Matching engine not found for instrument {instrument_id}\");\n        }\n    }\n\n    fn process_modify_submitted_order(&self, command: &ModifyOrder) -> bool {\n        let Some(order) = self\n            .cache\n            .borrow()\n            .order(&command.client_order_id)\n            .map(|o| o.clone())\n        else {\n            return false;\n        };\n\n        let modifies_submitted_order = matches!(order.status(), OrderStatus::Submitted)\n            || (matches!(order.status(), OrderStatus::PendingUpdate)\n                && order\n                    .previous_status()\n                    .is_some_and(|status| matches!(status, OrderStatus::Submitted)));","sourceCodeStart":1904,"sourceCodeEnd":1940,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/exchange.rs#L1904-L1940","documentation":"When processing a trading command (submit/modify/cancel/cancel-all) the exchange looked up the `MatchingEngine` for the command's instrument ID and, finding none, panicked. The engine map must contain an entry for every instrument whose orders are routed to this venue.","triggerScenarios":"`TradingCommand::CancelAllOrders` (or any single-instrument trading command) targeting an `instrument_id` with no registered matching engine in `exchange.matching_engines`.","commonSituations":"Cancelling orders on an instrument that was never registered with the venue; commands broadcast to all instruments where some instruments lack engines; data/config mismatch after changing instrument definitions (e.g. different venue or expiration).","solutions":["Register the instrument (matching engine) with the venue before routing commands to it.","Filter or gate commands so only instruments registered with this exchange are routed to it.","Log/instrument-coverage-check which instrument IDs the strategy uses versus venue-registered instruments."],"exampleFix":"// before\nengine.cancel_all_orders(instrument_id); // instrument never registered\n// after\nengine.add_venue(SimulatedExchangeConfig {\n    instruments: vec![instrument],\n    ..Default::default()\n});\nengine.cancel_all_orders(instrument_id);","handlingStrategy":"validation","validationCode":"// before routing commands\nif !venue.instrument_ids().contains(&instrument_id) {\n    eprintln!(\"skipping command for unregistered instrument {instrument_id}\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Route commands only to venues that registered the instrument","Avoid broadcasting cancel-all across venues with disjoint instrument sets","Verify venue/instrument IDs match after any instrument definition change"],"tags":["backtest","panic","matching-engine","rust"],"backgroundTag":"resource-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}