{"record":{"id":"8d5acf969674d92c","repo":"nautechsystems/nautilus_trader","slug":"cannot-market-exit-strategy-strategy-id-not-fou","errorCode":null,"errorMessage":"Cannot market exit strategy, {strategy_id} not found","messagePattern":"Cannot market exit strategy, (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1388,"sourceCode":"    ///\n    /// # Errors\n    ///\n    /// Returns an error if the strategy is not registered or its control endpoint is missing.\n    pub fn market_exit_strategy(\n        trader: &Rc<RefCell<Self>>,\n        strategy_id: &StrategyId,\n    ) -> anyhow::Result<()> {\n        let handler = trader.borrow().strategy_command_handler(*strategy_id)?;\n        handler.handle(&StrategyCommand::ExitMarket);\n        Ok(())\n    }\n\n    fn strategy_command_handler(\n        &self,\n        strategy_id: StrategyId,\n    ) -> anyhow::Result<TypedHandler<StrategyCommand>> {\n        if !self.strategy_ids.contains(&strategy_id) {\n            anyhow::bail!(\"Cannot market exit strategy, {strategy_id} not found\");\n        }\n\n        let endpoint = strategy_control_endpoint(strategy_id);\n        let handler = {\n            let msgbus = get_message_bus();\n            msgbus\n                .borrow_mut()\n                .endpoint_map::<StrategyCommand>()\n                .get(endpoint)\n                .cloned()\n        };\n\n        let Some(handler) = handler else {\n            anyhow::bail!(\n                \"Cannot exit market for strategy {strategy_id}: control endpoint '{}' not registered\",\n                endpoint.as_str()\n            );\n        };","sourceCodeStart":1370,"sourceCodeEnd":1406,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1370-L1406","documentation":"Registration guard behind strategy_command_handler: market_exit_strategy needs a command handler for the strategy, but the strategy_id is not registered with the trader, so the exit-market command cannot be routed.","triggerScenarios":"Thrown at crates/system/src/trader.rs:1388 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the strategy with the trader before issuing a market exit","Verify the strategy ID is correct and currently registered"],"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-14T00:17:10.932Z"}