{"record":{"id":"0c12a36fdb09f044","repo":"nautechsystems/nautilus_trader","slug":"binancefuturesdataclient-requires-usdm-or-coinm-pr","errorCode":null,"errorMessage":"BinanceFuturesDataClient requires UsdM or CoinM product type, was {product_type:?}","messagePattern":"BinanceFuturesDataClient requires UsdM or CoinM product type, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":166,"sourceCode":"\nimpl BinanceFuturesDataClient {\n    /// Creates a new [`BinanceFuturesDataClient`] instance.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the client fails to initialize or if the product type\n    /// is not a futures type (UsdM or CoinM).\n    pub fn new(\n        client_id: ClientId,\n        config: BinanceDataClientConfig,\n        product_type: BinanceProductType,\n    ) -> anyhow::Result<Self> {\n        config.validate()?;\n\n        match product_type {\n            BinanceProductType::UsdM | BinanceProductType::CoinM => {}\n            _ => {\n                anyhow::bail!(\n                    \"BinanceFuturesDataClient requires UsdM or CoinM product type, was {product_type:?}\"\n                );\n            }\n        }\n\n        let clock = get_atomic_clock_realtime();\n        let data_sender = get_data_event_sender();\n        let socket_factory = SocketControlFactory::new(client_id, Some(*BINANCE_VENUE));\n        let api_key = config\n            .api_key\n            .as_ref()\n            .map(|value| value.expose_secret().to_owned());\n        let api_secret = config\n            .api_secret\n            .as_ref()\n            .map(|value| value.expose_secret().to_owned());\n        let proxy_url = config\n            .proxy_url","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L148-L184","documentation":"BinanceFuturesDataClient::new asserts that the configured BinanceProductType is UsdM or CoinM after validating the config. Any other product type (e.g. Spot) cannot be served by the futures data client and construction fails with this error.","triggerScenarios":"Directly constructing BinanceFuturesDataClient::new(client_id, config, product_type) with product_type = Spot or another non-futures variant.","commonSituations":"Wiring a Binance data client manually (not via the factory) and passing the wrong product type; a config that says futures but the enum resolved to Spot; copy-pasted client construction code from a spot example.","solutions":["Pass BinanceProductType::UsdM or BinanceProductType::CoinM when constructing the futures data client","Use the spot data client for Spot product type instead of the futures client","Prefer the client factory, which routes product types to the correct client implementation"],"exampleFix":"// before\nlet client = BinanceFuturesDataClient::new(client_id, config, BinanceProductType::Spot)?;\n// after\nlet client = BinanceFuturesDataClient::new(client_id, config, BinanceProductType::UsdM)?;","handlingStrategy":"validation","validationCode":"fn assert_futures_product(pt: BinanceProductType) -> Result<(), String> {\n    match pt {\n        BinanceProductType::UsdM | BinanceProductType::CoinM => Ok(()),\n        other => Err(format!(\"futures client requires UsdM/CoinM, got {other:?}\")),\n    }\n}","typeGuard":"fn is_futures_product(pt: BinanceProductType) -> bool {\n    matches!(pt, BinanceProductType::UsdM | BinanceProductType::CoinM)\n}","tryCatchPattern":"match BinanceFuturesDataClient::new(client_id, config, product_type) {\n    Err(e) if e.to_string().contains(\"requires UsdM or CoinM\") => {\n        eprintln!(\"Use the spot data client for Spot product type: {e}\");\n    }\n    r => r?,\n}","preventionTips":["Construct clients via the factory rather than calling client constructors directly","Match client class to product type: futures client for UsdM/CoinM, spot client for Spot","Validate product_type in config before wiring the trading node"],"tags":["rust","binance","futures","product-type","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}