{"record":{"id":"2c1b553d2d3fbe2b","repo":"nautechsystems/nautilus_trader","slug":"livenode-cannot-be-used-with-backtest-environment","errorCode":null,"errorMessage":"LiveNode cannot be used with Backtest environment","messagePattern":"LiveNode cannot be used with Backtest environment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/live/src/node/config.rs","lineNumber":64,"sourceCode":"    event_store::EventStoreConfig,\n};\nuse nautilus_trading::ImportableControllerConfig;\nuse rust_decimal::Decimal;\nuse serde::{Deserialize, Serialize};\n\npub use super::queue::QueueMonitorConfig;\nuse crate::execution::manager::ExecutionManagerConfig;\n\n/// The default rate limit string used for order submission and modification.\nconst DEFAULT_ORDER_RATE_LIMIT: &str = \"100/00:00:01\";\nconst RUST_RUNTIME_UNSUPPORTED: &str = \"not supported by the Rust live runtime yet\";\nconst RATE_LIMIT_FORMAT: &str = \"expected 'limit/HH:MM:SS'\";\n\npub(crate) fn validate_live_environment(environment: Environment) -> anyhow::Result<()> {\n    match environment {\n        Environment::Sandbox | Environment::Live => Ok(()),\n        Environment::Backtest => {\n            anyhow::bail!(\"LiveNode cannot be used with Backtest environment\")\n        }\n    }\n}\n\n/// Configuration for live data engines.\n#[cfg_attr(\n    feature = \"python\",\n    pyo3::pyclass(module = \"nautilus_trader.live\", from_py_object)\n)]\n#[cfg_attr(\n    feature = \"python\",\n    pyo3_stub_gen::derive::gen_stub_pyclass(module = \"nautilus_trader.live\")\n)]\n#[expect(\n    clippy::struct_excessive_bools,\n    reason = \"config fields mirror the existing Python live data engine surface\"\n)]\n#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, bon::Builder)]","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/node/config.rs#L46-L82","documentation":"LiveNode configuration validation only permits Sandbox and Live environments. A LiveNode is the live/sandbox runtime; a Backtest environment requires the backtest engine instead, so validation rejects it up front.","triggerScenarios":"Constructing a LiveNode via new/from_config/build with a LiveNodeConfig whose environment is Environment::Backtest.","commonSituations":"Reusing one config struct for both backtest and live runs and forgetting to switch the environment; programmatically defaulting to Backtest; a config file copied from a backtest script.","solutions":["Set the config environment to Environment::Live or Environment::Sandbox for a LiveNode.","Use the backtest engine/API for Backtest environment runs instead of LiveNode.","Branch on the intended mode and construct the appropriate node type."],"exampleFix":"// before\nlet config = LiveNodeConfig::builder().environment(Environment::Backtest).build();\nlet node = LiveNode::from_config(config)?;\n// after\nlet config = LiveNodeConfig::builder().environment(Environment::Live).build();\nlet node = LiveNode::from_config(config)?;","handlingStrategy":"validation","validationCode":"assert_ne!(config.environment(), Environment::Backtest, \"LiveNode cannot run backtests\");","typeGuard":"fn is_live_compatible(env: Environment) -> bool { matches!(env, Environment::Live | Environment::Sandbox) }","tryCatchPattern":null,"preventionTips":["Gate LiveNode construction behind an environment check.","Use separate config files for backtest vs live runs.","Centralize environment selection so it cannot drift between paths."],"tags":["rust","environment","config-validation","backtest"],"backgroundTag":"invalid-enum-value","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"}