{"record":{"id":"209f48d97ac6329d","repo":"nautechsystems/nautilus_trader","slug":"strategy-not-registered-strategy-id-is-not-set","errorCode":null,"errorMessage":"Strategy not registered: strategy_id is not set","messagePattern":"Strategy not registered: strategy_id is not set","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/trading/src/strategy/mod.rs","lineNumber":2443,"sourceCode":"    msgbus::send_trading_command(endpoint, command);\n}\n\nfn log_cmd_send(command: &TradingCommand) {\n    if let Some(id) = command.strategy_id() {\n        log::info!(\"{id} {CMD}{SEND} {command}\");\n    } else {\n        log::info!(\"{CMD}{SEND} {command}\");\n    }\n}\n\nfn registered_trader_id(core: &StrategyCore) -> anyhow::Result<TraderId> {\n    core.trader_id()\n        .ok_or_else(|| anyhow::anyhow!(\"Strategy not registered: trader_id is not set\"))\n}\n\nfn registered_strategy_id(core: &StrategyCore) -> anyhow::Result<StrategyId> {\n    core.strategy_id()\n        .ok_or_else(|| anyhow::anyhow!(\"Strategy not registered: strategy_id is not set\"))\n}\n\nfn required_account_id(order: &OrderAny, operation: &str) -> anyhow::Result<AccountId> {\n    order.account_id().ok_or_else(|| {\n        anyhow::anyhow!(\n            \"Cannot generate {operation} event for {}: account_id is not set\",\n            order.client_order_id()\n        )\n    })\n}\n\n#[cfg(test)]\nmod tests {\n    use std::{cell::RefCell, rc::Rc};\n\n    use nautilus_common::{\n        actor::{\n            DataActor,","sourceCodeStart":2425,"sourceCodeEnd":2461,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/strategy/mod.rs#L2425-L2461","documentation":"Raised by `registered_strategy_id` when `StrategyCore.strategy_id()` is None, i.e. the strategy has no StrategyId because it was never registered. Callers use it to stamp commands and cache entries with the strategy identity before order operations.","triggerScenarios":"Calling set_external_order_instrument_ids, submit_order_list, modify_order(s), cancel_order(s) on an unregistered strategy instance (constructed but never added to a trader/node).","commonSituations":"Same as trader_id case: manually constructed strategies in scripts/tests, strategies removed from the trader, or a failed/incomplete registration flow.","solutions":["Add the strategy to the trading node (trader.add_strategy) before issuing order operations.","Confirm the strategy's on_start/registration path ran (strategy_id set during register).","Use the framework's builder or fixtures to construct and register strategies in tests.","Guard entry points with a registered check if the strategy can be used pre-registration."],"exampleFix":"// before\nlet strategy = MyStrategy::new(config);\nstrategy.cancel_all_orders(None)?; // strategy_id unset\n// after\nlet strategy = trader.add_strategy(MyStrategy::new(config))?;\nstrategy.cancel_all_orders(None)?;","handlingStrategy":"validation","validationCode":"if strategy.core().strategy_id().is_none() { return Err(\"strategy_id unset: register strategy first\".into()); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = strategy.cancel_all_orders(None) {\n    if e.to_string().contains(\"strategy_id is not set\") { log::error!(\"strategy never registered: {e}\"); }\n}","preventionTips":["Register the strategy with the node before any order operations","Use builder/harness fixtures that perform registration in tests","Log strategy_id at startup to confirm registration completed"],"tags":["rust","strategy-registration","lifecycle"],"backgroundTag":"missing-required-config-field","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"}