{"record":{"id":"da3587af8d438e6b","repo":"nautechsystems/nautilus_trader","slug":"binance-us-supports-the-live-environment-only","errorCode":null,"errorMessage":"Binance US supports the Live environment only","messagePattern":"Binance US supports the Live environment only","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/config.rs","lineNumber":258,"sourceCode":"    }\n}\n\nimpl BinanceDataClientConfig {\n    /// Validates Binance data client configuration.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error for invalid receive-window, provider, or Binance US settings.\n    pub fn validate(&self) -> anyhow::Result<()> {\n        validate_recv_window(self.recv_window_ms)?;\n        self.instrument_provider.validate(self.product_type)?;\n\n        if self.us {\n            anyhow::ensure!(\n                self.product_type == BinanceProductType::Spot,\n                \"Binance US supports Spot clients only\"\n            );\n            anyhow::ensure!(\n                self.environment == BinanceEnvironment::Live,\n                \"Binance US supports the Live environment only\"\n            );\n            anyhow::ensure!(\n                self.spot_market_data_mode == BinanceSpotMarketDataMode::Json,\n                \"Binance US market data requires spot_market_data_mode=Json\"\n            );\n        }\n\n        Ok(())\n    }\n}\n\nimpl ClientConfig for BinanceDataClientConfig {\n    fn as_any(&self) -> &dyn Any {\n        self\n    }\n}","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/config.rs#L240-L276","documentation":"With us=True the data client must run against the Live environment, since binance.us provides no testnet/demo endpoints. BinanceDataClientConfig.validate rejects any other BinanceEnvironment (Testnet or Demo) before the client is created.","triggerScenarios":"BinanceDataClientConfig(us=True, environment='TESTNET' or 'DEMO') — typically a leftover environment toggle from development against the global testnet while the us flag is also enabled.","commonSituations":"Switching a testnet-developed strategy to binance.us but forgetting to flip environment back to LIVE; templates that hardcode environment='TESTNET'; sharing one config dict between global and US clients.","solutions":["Set environment='LIVE' (the default) when us=True.","Keep testnet development on the global exchange: us=False, environment='TESTNET'.","Assert the invariant at config build time: if cfg.us, cfg.environment == 'LIVE'."],"exampleFix":"# before\nBinanceDataClientConfig(us=True, environment=BinanceEnvironment.TESTNET)\n\n# after\nBinanceDataClientConfig(us=True, environment=BinanceEnvironment.LIVE)","handlingStrategy":"validation","validationCode":"if config.us:\n    assert config.environment == BinanceEnvironment.LIVE, \\\n        'binance.us has no testnet; use us=False for TESTNET'\nconfig.validate()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair us=True exclusively with environment='LIVE'.","Develop against the global testnet (us=False) and flip both flags together for US live.","Add a boot-time assertion for the us/LIVE invariant."],"tags":["binance","config","binance-us","environment","validation"],"backgroundTag":"config-validation-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}