{"record":{"id":"86f7844f4d566180","repo":"nautechsystems/nautilus_trader","slug":"matching-engine-not-found-for-instrument-order-in","errorCode":null,"errorMessage":"Matching engine not found for instrument {order_instrument_id}","messagePattern":"Matching engine not found for instrument (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/backtest/src/exchange.rs","lineNumber":1886,"sourceCode":"\n        let account_id = if let Some(exec_client) = &self.exec_client {\n            exec_client.account_id()\n        } else {\n            panic!(\"Execution client should be initialized\");\n        };\n\n        if let TradingCommand::SubmitOrderList(ref command) = command {\n            let mut orders: Vec<OrderAny> = self\n                .cache\n                .borrow()\n                .orders_for_ids(&command.order_list.client_order_ids, command);\n\n            for order in &mut orders {\n                let order_instrument_id = order.instrument_id();\n                if let Some(matching_engine) = self.matching_engines.get_mut(&order_instrument_id) {\n                    matching_engine.process_order(order, account_id);\n                } else {\n                    panic!(\"Matching engine not found for instrument {order_instrument_id}\");\n                }\n            }\n\n            return;\n        }\n\n        if let Some(matching_engine) = self.matching_engines.get_mut(&instrument_id) {\n            match command {\n                TradingCommand::SubmitOrder(command) => {\n                    let mut order = self\n                        .cache\n                        .borrow()\n                        .order(&command.client_order_id)\n                        .map(|o| o.clone())\n                        .expect(\"Order must exist in cache\");\n                    matching_engine.process_order(&mut order, account_id);\n                }\n                TradingCommand::ModifyOrder(ref command) => {","sourceCodeStart":1868,"sourceCodeEnd":1904,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/exchange.rs#L1868-L1904","documentation":"While submitting an order list, the exchange could not find a `MatchingEngine` registered for the order's instrument ID and panicked. Each traded instrument in the backtest needs a matching engine that simulates order matching; submitting orders for an instrument with no engine means the venue cannot process them.","triggerScenarios":"`SubmitOrderList` command where one of the orders' `instrument_id` has no entry in `exchange.matching_engines` (never registered via the venue config).","commonSituations":"Orders created for an instrument not declared in the backtest venue configuration; typo'd or synthesized instrument IDs; running a backtest against data from an instrument that was not added to the exchange config.","solutions":["Register the instrument in the venue configuration (`add_venue` with the instrument) so a matching engine is created.","Verify every order's `instrument_id` exactly matches a registered instrument.","Validate instrument coverage before the run (compare cache instruments to venue-registered instruments)."],"exampleFix":"// before\nengine.add_data(quote_data); // instrument on data only\nengine.run(); // panic: no matching engine\n// after\nengine.add_venue(SimulatedExchangeConfig {\n    instruments: vec![instrument],\n    ..Default::default()\n});\nengine.add_data(quote_data);\nengine.run();","handlingStrategy":"validation","validationCode":"// before submitting\nlet registered: HashSet<InstrumentId> = venue.instruments().iter().map(|i| i.id()).collect();\nfor order in orders {\n    assert!(registered.contains(&order.instrument_id()), \"instrument not registered: {}\", order.instrument_id());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive order instrument IDs from registered instruments, never hardcoded strings","Cross-check strategy instrument lists against venue config at startup","Add a startup assertion comparing cache instruments to venue instruments"],"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"}