{"record":{"id":"9c13613460672400","repo":"nautechsystems/nautilus_trader","slug":"cannot-update-instrument-with","errorCode":null,"errorMessage":"Cannot update instrument {} with {}","messagePattern":"Cannot update instrument (.+?) with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/matching_engine/mod.rs","lineNumber":1239,"sourceCode":"    }\n\n    #[must_use]\n    pub const fn get_core(&self) -> &OrderMatchingCore {\n        &self.core\n    }\n\n    pub fn set_fill_at_market(&mut self, value: bool) {\n        self.fill_at_market = value;\n    }\n\n    /// Updates the instrument definition used by this matching engine.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if `instrument.id()` does not match this engines instrument ID.\n    pub fn update_instrument(&mut self, instrument: InstrumentAny) -> anyhow::Result<()> {\n        if instrument.id() != self.instrument.id() {\n            anyhow::bail!(\n                \"Cannot update instrument {} with {}\",\n                self.instrument.id(),\n                instrument.id()\n            );\n        }\n\n        let changed = instrument.price_increment() != self.instrument.price_increment()\n            || instrument.price_precision() != self.instrument.price_precision()\n            || instrument.size_precision() != self.instrument.size_precision();\n\n        if changed {\n            self.core\n                .update_price_increment(instrument.price_increment());\n            self.book.reset();\n            self.trade_consumption = 0;\n            self.bid_consumption.clear();\n            self.ask_consumption.clear();\n            self.queue_pending.clear();","sourceCodeStart":1221,"sourceCodeEnd":1257,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/matching_engine/mod.rs#L1221-L1257","documentation":"Guard in OrderMatchingEngine::update_instrument: the new instrument definition's ID differs from the ID this matching engine was created for, so swapping the definition would corrupt the engine's book state and the update is refused.","triggerScenarios":"Thrown at crates/execution/src/matching_engine/mod.rs:1239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Route the instrument to a matching engine created for that instrument ID","Create a new matching engine for the new instrument instead of updating an existing one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}