{"record":{"id":"35e60e4bdfcb027b","repo":"nautechsystems/nautilus_trader","slug":"cannot-exit-market-for-strategy-strategy-id-con","errorCode":null,"errorMessage":"Cannot exit market for strategy {strategy_id}: control endpoint '{}' not registered","messagePattern":"Cannot exit market for strategy (.+?): control endpoint '(.+?)' not registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1402,"sourceCode":"        &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        };\n\n        Ok(handler)\n    }\n\n    /// Removes the strategy with the given `strategy_id`.\n    ///\n    /// Will stop the strategy first if it is currently running. Disposes the strategy\n    /// and removes it from the trader's tracking along with its event subscriptions.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the strategy is not registered, the cache is already borrowed, or\n    /// disposal fails. A cache borrow failure preserves the strategy registration and its external\n    /// order claims. A failed disposal keeps the strategy registered and tracked, and leaves it","sourceCodeStart":1384,"sourceCodeEnd":1420,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1384-L1420","documentation":"The trader's strategy_command_handler looks up a registered control endpoint for the given strategy via endpoint_map and bails when no handler is registered under that endpoint name. This means commands like 'exit market' cannot be routed to the strategy because it never registered a handler for that endpoint string.","triggerScenarios":"Calling a trader command path (e.g. exit-market style commands) with an `endpoint` whose handler was never registered by the strategy, the strategy being removed before the command arrives, or an endpoint name typo/mismatch between caller and strategy registration.","commonSituations":"Sending control commands to a strategy that hasn't started or registered its command endpoint; a renamed or refactored endpoint string on the strategy side while callers still use the old name; strategy was already removed/retired.","solutions":["Verify the strategy registers the control endpoint (endpoint_map) with the exact name being requested before commands are sent","Check for typos or case differences in the endpoint string between caller and registration","Ensure the strategy is still running/registered in the trader when the command is sent","Add logging of the registered endpoint keys to compare against the requested endpoint"],"exampleFix":"// before: handler assumes endpoint exists\ntrader.command_strategy(strategy_id, endpoint, cmd)?;\n// after: register endpoint on strategy start\nfn on_start(&mut self) -> anyhow::Result<()> {\n    self.register_endpoint(\"exit_market\", Self::handle_exit_market);\n    Ok(())\n}","handlingStrategy":"validation","validationCode":"if !trader.has_endpoint(&strategy_id, &endpoint) { return Err(anyhow!(\"endpoint {} not registered\", endpoint.as_str())); }","typeGuard":"fn is_endpoint_registered(trader: &Trader, id: &StrategyId, ep: &Endpoint) -> bool { trader.has_endpoint(id, ep) }","tryCatchPattern":null,"preventionTips":["Register all control endpoints in the strategy's on_start before accepting commands","Use shared constants for endpoint names between caller and strategy","Log the set of registered endpoints when a lookup fails"],"tags":["rust","trader","endpoint"],"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-14T05:17:10.506Z"}