{"record":{"id":"f72afa856efbc5b9","repo":"nautechsystems/nautilus_trader","slug":"cannot-stop-strategy-strategy-id-not-found","errorCode":null,"errorMessage":"Cannot stop strategy, {strategy_id} not found","messagePattern":"Cannot stop strategy, (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1351,"sourceCode":"    /// Returns an error if the strategy is not registered or cannot be started.\n    pub fn start_strategy(&self, strategy_id: &StrategyId) -> anyhow::Result<()> {\n        if !self.strategy_ids.contains(strategy_id) {\n            anyhow::bail!(\"Cannot start strategy, {strategy_id} not found\");\n        }\n        start_component(&strategy_id.inner())\n    }\n\n    /// Stops the strategy with the given `strategy_id`.\n    ///\n    /// Respects the `manage_stop` behavior - if the strategy's stop function\n    /// returns `false`, the component stop is deferred until market exit completes.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the strategy is not registered or cannot be stopped.\n    pub fn stop_strategy(&mut self, strategy_id: &StrategyId) -> anyhow::Result<()> {\n        if !self.strategy_ids.contains(strategy_id) {\n            anyhow::bail!(\"Cannot stop strategy, {strategy_id} not found\");\n        }\n\n        let should_proceed = self\n            .strategy_stop_fns\n            .get_mut(strategy_id)\n            .is_none_or(|stop_fn| stop_fn());\n\n        if should_proceed {\n            stop_component(&strategy_id.inner())?;\n        }\n\n        Ok(())\n    }\n\n    /// Exits the market for the strategy with the given `strategy_id`.\n    ///\n    /// Sends a strategy command to the strategy's control endpoint. The strategy\n    /// then performs its own managed market exit.","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1333-L1369","documentation":"stop_strategy was called with a StrategyId that is not in the trader's registered strategy set; the strategy was never added or has already been removed, so there is no running component to stop and the call fails fast.","triggerScenarios":"Thrown at crates/system/src/trader.rs:1351 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the strategy before stopping it","Verify the strategy ID against the trader's registered strategy IDs"],"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"}