nautechsystems/nautilus_trader · error · anyhow::Error

Binance US supports the Live environment only

Error message

Binance US supports the Live environment only

What it means

Binance US is only reachable in the Live environment; the adapter does not support Testnet/demo environments for Binance US. validate() throws this error when `us` is true but `environment` is anything other than BinanceEnvironment::Live.

Solutions

  1. Set environment = BinanceEnvironment::Live when us = true.
  2. Set us = false and use Binance global Testnet if you need a sandbox environment.
  3. Test against Binance US Live with small size instead of testnet.

Example fix

// before
let config = BinanceDataClientConfig { us: true, environment: BinanceEnvironment::Testnet, .. };
// after
let config = BinanceDataClientConfig { us: true, environment: BinanceEnvironment::Live, .. };
Defensive patterns

Strategy: validation

Validate before calling

fn us_env_ok(us: bool, environment: BinanceEnvironment) -> bool {
    !us || environment == BinanceEnvironment::Live
}

Prevention

When it happens

Trigger: Constructing BinanceDataClientConfig with us=true and environment set to a non-Live value (e.g. Testnet or Demo), then calling validate().

Common situations: Trying to paper-trade against testnet with a Binance US account; copy-pasting a global-Binance testnet config and adding us=true.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/config.rs:261

    }
}

impl BinanceDataClientConfig {
    /// Validates Binance data client configuration.
    ///
    /// # Errors
    ///
    /// Returns an error for invalid receive-window, provider, or Binance US settings.
    pub fn validate(&self) -> anyhow::Result<()> {
        validate_recv_window(self.recv_window_ms)?;
        self.instrument_provider.validate(self.product_type)?;

        if self.us {
            anyhow::ensure!(
                self.product_type == BinanceProductType::Spot,
                "Binance US supports Spot clients only"
            );
            anyhow::ensure!(
                self.environment == BinanceEnvironment::Live,
                "Binance US supports the Live environment only"
            );
            anyhow::ensure!(
                self.spot_market_data_mode == BinanceSpotMarketDataMode::Json,
                "Binance US market data requires spot_market_data_mode=Json"
            );
        }

        Ok(())
    }
}

impl ClientConfig for BinanceDataClientConfig {
    fn as_any(&self) -> &dyn Any {
        self
    }
}

View on GitHub (pinned to 18893faf8b)