{"record":{"id":"dbbf7a67dab73246","repo":"nautechsystems/nautilus_trader","slug":"spot-ticker-requires-a-binance-instrument","errorCode":null,"errorMessage":"Spot ticker requires a BINANCE instrument","messagePattern":"Spot ticker requires a BINANCE instrument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/data.rs","lineNumber":1789,"sourceCode":"\n    fn is_disconnected(&self) -> bool {\n        !self.is_connected()\n    }\n\n    fn subscribe(&mut self, cmd: SubscribeCustomData) -> anyhow::Result<()> {\n        if cmd.data_type.type_name() != \"BinanceSpotTicker\" {\n            log::warn!(\n                \"Unsupported custom data subscription: {}\",\n                cmd.data_type.type_name()\n            );\n            return Ok(());\n        }\n        anyhow::ensure!(\n            self.spot_market_data_mode == BinanceSpotMarketDataMode::Json,\n            \"Binance Spot 24-hour ticker custom data requires JSON market-data mode\"\n        );\n        let instrument_id = Self::required_instrument_id_metadata(&cmd.data_type)?;\n        anyhow::ensure!(\n            instrument_id.venue == self.venue(),\n            \"Spot ticker requires a BINANCE instrument\"\n        );\n        let should_subscribe = {\n            let previous = self\n                .ticker_refs\n                .load()\n                .get(&instrument_id)\n                .copied()\n                .unwrap_or(0);\n            self.ticker_refs\n                .rcu(|refs| *refs.entry(instrument_id).or_insert(0) += 1);\n            previous == 0\n        };\n\n        if should_subscribe {\n            let ws = self.ws_client.clone();\n            let stream = format!(\"{}@ticker\", instrument_id.symbol.as_str().to_lowercase());","sourceCodeStart":1771,"sourceCodeEnd":1807,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/data.rs#L1771-L1807","documentation":"The 24-hour ticker custom-data subscription extracted an instrument_id from the command metadata, but its venue is not BINANCE (the venue this Spot data client serves). The client validates that ticker requests target BINANCE instruments before registering the subscription.","triggerScenarios":"Subscribing to the Binance spot 24hr ticker custom data type with an instrument_id whose venue is another venue (e.g. BYBIT, ETH perp IDs, or a synthetic venue) supplied via data-type metadata.","commonSituations":"Copy-pasted instrument IDs across venues; strategy config pointing at the wrong venue; building the custom data type with an instrument from a different adapter.","solutions":["Pass a BINANCE-spot instrument_id in the ticker data type metadata (use the instrument ID registered with this client).","Verify the instrument was loaded from the Binance adapter's instrument provider.","Fix the strategy/config that constructs the Subscribe command."],"exampleFix":"// before\nlet data_type = DataType::new(\"BinanceSpotTicker24h\").with_metadata(\"instrument_id\", bybit_instrument_id);\n// after\nlet data_type = DataType::new(\"BinanceSpotTicker24h\").with_metadata(\"instrument_id\", binance_spot_instrument_id); // venue == BINANCE","handlingStrategy":"validation","validationCode":"fn ensure_binance_instrument(instrument_id: &InstrumentId, venue: Venue) -> Result<(), String> {\n    if instrument_id.venue == venue { Ok(()) } else { Err(format!(\"{} is not a BINANCE instrument\", instrument_id)) }\n}","typeGuard":"fn is_binance_instrument(id: &InstrumentId) -> bool {\n    id.venue.as_str() == \"BINANCE\"\n}","tryCatchPattern":"if let Err(e) = client.subscribe(cmd) {\n    if e.to_string().contains(\"requires a BINANCE instrument\") {\n        log::error!(\"bad instrument metadata: {e}\");\n    } else { return Err(e.into()); }\n}","preventionTips":["Source instrument IDs from the Binance adapter's instrument provider, not literals.","Assert venue == BINANCE when constructing ticker data-type metadata.","Keep per-venue strategy configs separated.","Add unit tests covering metadata construction for custom data types."],"tags":["binance","validation","instrument-id","subscription"],"backgroundTag":"invalid-argument-value","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"}