{"record":{"id":"f03dac056182f10a","repo":"nautechsystems/nautilus_trader","slug":"futures-mark-price-requires-a-binance-instrument","errorCode":null,"errorMessage":"Futures mark price requires a BINANCE instrument","messagePattern":"Futures mark price requires a BINANCE instrument","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":1856,"sourceCode":"    }\n\n    fn is_connected(&self) -> bool {\n        self.is_connected.load(Ordering::Relaxed)\n    }\n\n    fn is_disconnected(&self) -> bool {\n        !self.is_connected()\n    }\n\n    fn subscribe(&mut self, cmd: SubscribeCustomData) -> anyhow::Result<()> {\n        let data_type = cmd.data_type.type_name();\n        if data_type == \"BinanceFuturesTicker\" {\n            return subscribe_ticker(self, &cmd.data_type);\n        }\n\n        if data_type == \"BinanceFuturesMarkPriceUpdate\" {\n            let instrument_id = Self::required_instrument_id_metadata(&cmd.data_type)?;\n            anyhow::ensure!(\n                instrument_id.venue == self.venue(),\n                \"Futures mark price requires a BINANCE instrument\"\n            );\n            let should_subscribe = {\n                let previous = self\n                    .mark_price_refs\n                    .load()\n                    .get(&instrument_id)\n                    .copied()\n                    .unwrap_or(0);\n                self.mark_price_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!(","sourceCodeStart":1838,"sourceCodeEnd":1874,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L1838-L1874","documentation":"Subscribing to BinanceFuturesMarkPriceUpdate requires an instrument ID whose venue is BINANCE. The handler extracts the required instrument_id from the subscription metadata and rejects subscriptions for any other venue, since mark price streams are a Binance-Futures-specific data type.","triggerScenarios":"Calling SubscribeData for data_type \"BinanceFuturesMarkPriceUpdate\" with metadata instrument_id set to an instrument from a different venue (e.g. BYBIT, OKX) or an ID that failed venue parsing.","commonSituations":"Multi-venue strategies generically subscribing all instruments to every data type; passing a synthetic/backtest instrument ID with the wrong venue string; typos in the venue component of the instrument ID.","solutions":["Use an instrument ID with venue BINANCE for the mark price subscription","Filter subscription loops so Binance-specific data types are only requested for BINANCE instruments","Check the instrument ID format (e.g. BTCUSDT-PERP.BINANCE) for venue typos"],"exampleFix":"// before\nsubscribe(\"BinanceFuturesMarkPriceUpdate\", \"ETHUSDT-PERP.BYBIT\")\n// after\nsubscribe(\"BinanceFuturesMarkPriceUpdate\", \"ETHUSDT-PERP.BINANCE\")","handlingStrategy":"validation","validationCode":"fn can_subscribe_mark_price(instrument_id: &str) -> bool {\n    instrument_id.ends_with(\".BINANCE\")\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::warn!(\"skipping non-Binance instrument for mark price\");\n    } else { return Err(e); }\n}","preventionTips":["Filter instrument lists by venue before subscribing Binance-specific data types","Validate instrument ID strings include the .BINANCE suffix","Use venue-scoped client instances per venue"],"tags":["validation","subscription","instrument-id","binance-futures"],"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"}