{"record":{"id":"4568a118e05cacc0","repo":"nautechsystems/nautilus_trader","slug":"cannot-subscribe-l1-mbp-and-l2-mbp-for-the-same-bi","errorCode":null,"errorMessage":"cannot subscribe L1_MBP and L2_MBP for the same Binance Futures instrument","messagePattern":"cannot subscribe L1_MBP and L2_MBP for the same Binance Futures instrument","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":1973,"sourceCode":"            \"subscribe_instruments: Binance Futures instruments are fetched via HTTP on connect\"\n        );\n        Ok(())\n    }\n\n    fn subscribe_instrument(&mut self, _cmd: SubscribeInstrument) -> anyhow::Result<()> {\n        log::debug!(\n            \"subscribe_instrument: Binance Futures instruments are fetched via HTTP on connect\"\n        );\n        Ok(())\n    }\n\n    fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {\n        if cmd.book_type == BookType::L1_MBP {\n            anyhow::ensure!(\n                cmd.depth.is_none_or(|depth| depth.get() == 1),\n                \"Binance Futures L1_MBP supports depth 1 only\"\n            );\n            anyhow::ensure!(\n                !self.book_subscriptions.contains_key(&cmd.instrument_id),\n                \"cannot subscribe L1_MBP and L2_MBP for the same Binance Futures instrument\"\n            );\n            self.l1_book_subscriptions.rcu(|subscriptions| {\n                *subscriptions.entry(cmd.instrument_id).or_insert(0) += 1;\n            });\n            self.subscribe_top_of_book(cmd.instrument_id);\n            return Ok(());\n        }\n\n        if cmd.book_type != BookType::L2_MBP {\n            anyhow::bail!(\"Binance Futures supports L1_MBP and L2_MBP order book subscriptions\");\n        }\n        anyhow::ensure!(\n            !self.l1_book_subscriptions.contains_key(&cmd.instrument_id),\n            \"cannot subscribe L1_MBP and L2_MBP for the same Binance Futures instrument\"\n        );\n","sourceCodeStart":1955,"sourceCodeEnd":1991,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L1955-L1991","documentation":"Binance Futures cannot mix an L1_MBP (book-ticker) subscription with an L2_MBP (depth) subscription for the same instrument. When subscribing L1, the handler checks book_subscriptions (L2 refs) and fails if the instrument already has an L2 subscription; the mirror check exists on the L2 path.","triggerScenarios":"Subscribing L1_MBP for an instrument that already has an active L2_MBP subscription (or vice versa) via SubscribeBookDeltas on Binance Futures.","commonSituations":"Two strategies in one node subscribing different book depths for the same symbol; a strategy falling back from L2 to L1 without unsubscribing first; shared subscription manager re-adding a cheaper top-of-book feed alongside the depth feed.","solutions":["Unsubscribe the existing L2_MBP subscription before requesting L1_MBP for that instrument","Standardize one book type per instrument across all strategies in the node","Use separate client instances if genuinely independent book views per strategy are needed"],"exampleFix":"// before\nsubscribe_book(L2_MBP, \"BTCUSDT-PERP.BINANCE\");\nsubscribe_book(L1_MBP, \"BTCUSDT-PERP.BINANCE\"); // panics/errors\n// after\nunsubscribe_book(L2_MBP, \"BTCUSDT-PERP.BINANCE\");\nsubscribe_book(L1_MBP, \"BTCUSDT-PERP.BINANCE\");","handlingStrategy":"validation","validationCode":"fn can_subscribe_l1(instrument_id: InstrumentId, l2_subs: &HashMap<InstrumentId, usize>) -> bool {\n    !l2_subs.contains_key(&instrument_id)\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.subscribe_book_deltas(cmd) {\n    if e.to_string().contains(\"L1_MBP and L2_MBP for the same\") {\n        log::warn!(\"book type conflict for {}; unsubscribing existing first\", cmd.instrument_id);\n        client.unsubscribe_book_deltas(opposite(cmd))?;\n        client.subscribe_book_deltas(cmd)?;\n    } else { return Err(e.into()); }\n}","preventionTips":["Track active book subscriptions per instrument in your strategy layer","Enforce one book type per instrument in the subscription manager","Unsubscribe before switching book depth types"],"tags":["validation","order-book","conflict","subscription"],"backgroundTag":"conflicting-config-options","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"}