nautechsystems/nautilus_trader · error

LiveNode cannot be used with Backtest environment

Error message

LiveNode cannot be used with Backtest environment

What it means

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.

Source

Thrown at crates/live/src/node/config.rs:64

    event_store::EventStoreConfig,
};
use nautilus_trading::ImportableControllerConfig;
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

pub use super::queue::QueueMonitorConfig;
use crate::execution::manager::ExecutionManagerConfig;

/// The default rate limit string used for order submission and modification.
const DEFAULT_ORDER_RATE_LIMIT: &str = "100/00:00:01";
const RUST_RUNTIME_UNSUPPORTED: &str = "not supported by the Rust live runtime yet";
const RATE_LIMIT_FORMAT: &str = "expected 'limit/HH:MM:SS'";

pub(crate) fn validate_live_environment(environment: Environment) -> anyhow::Result<()> {
    match environment {
        Environment::Sandbox | Environment::Live => Ok(()),
        Environment::Backtest => {
            anyhow::bail!("LiveNode cannot be used with Backtest environment")
        }
    }
}

/// Configuration for live data engines.
#[cfg_attr(
    feature = "python",
    pyo3::pyclass(module = "nautilus_trader.live", from_py_object)
)]
#[cfg_attr(
    feature = "python",
    pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
#[expect(
    clippy::struct_excessive_bools,
    reason = "config fields mirror the existing Python live data engine surface"
)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, bon::Builder)]

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set the config environment to Environment::Live or Environment::Sandbox for a LiveNode.
  2. Use the backtest engine/API for Backtest environment runs instead of LiveNode.
  3. Branch on the intended mode and construct the appropriate node type.

Example fix

// before
let config = LiveNodeConfig::builder().environment(Environment::Backtest).build();
let node = LiveNode::from_config(config)?;
// after
let config = LiveNodeConfig::builder().environment(Environment::Live).build();
let node = LiveNode::from_config(config)?;
Defensive patterns

Strategy: validation

Validate before calling

assert_ne!(config.environment(), Environment::Backtest, "LiveNode cannot run backtests");

Type guard

fn is_live_compatible(env: Environment) -> bool { matches!(env, Environment::Live | Environment::Sandbox) }

Prevention

When it happens

Trigger: Constructing a LiveNode via new/from_config/build with a LiveNodeConfig whose environment is Environment::Backtest.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/2c1b553d2d3fbe2b. Report an issue: GitHub.