{"record":{"id":"8c7d0a0379a77443","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-l1-mbp-supports-depth-1-only","errorCode":null,"errorMessage":"Binance Futures L1_MBP supports depth 1 only","messagePattern":"Binance Futures L1_MBP supports depth 1 only","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":1969,"sourceCode":"    }\n\n    fn subscribe_instruments(&mut self, _cmd: SubscribeInstruments) -> anyhow::Result<()> {\n        log::debug!(\n            \"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!(","sourceCodeStart":1951,"sourceCodeEnd":1987,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L1951-L1987","documentation":"For Binance Futures, L1_MBP (top-of-book) order book subscriptions must use depth exactly 1. The handler explicitly rejects any SubscribeBookDeltas with BookType::L1_MBP and a depth other than 1 (or missing-depth values that aren't 1), because the underlying book-ticker stream only provides best bid/ask.","triggerScenarios":"Calling SubscribeBookDeltas with book_type L1_MBP and depth set to e.g. 5, 10, 20 on a Binance Futures instrument.","commonSituations":"Reusing generic strategy code that requests depth-10 L1 snapshots across venues; copying L2 depth settings into an L1 subscription; config-driven depth values not adapted per venue.","solutions":["Set depth to 1 (or leave None, which passes the is_none_or check) when subscribing L1_MBP on Binance Futures","Use BookType::L2_MBP if you actually need deeper levels","Adjust per-venue config so depth values are venue-appropriate"],"exampleFix":"// before\nSubscribeBookDeltas { book_type: L1_MBP, depth: Some(10), .. }\n// after\nSubscribeBookDeltas { book_type: L1_MBP, depth: Some(1), .. } // or depth: None","handlingStrategy":"validation","validationCode":"fn valid_l1_depth(depth: Option<Depth>) -> bool {\n    depth.map_or(true, |d| d.get() == 1)\n}","typeGuard":"fn is_l1_depth_valid(cmd: &SubscribeBookDeltas) -> bool {\n    cmd.book_type != BookType::L1_MBP || cmd.depth.is_none_or(|d| d.get() == 1)\n}","tryCatchPattern":"match client.subscribe_book_deltas(cmd) {\n    Err(e) if e.to_string().contains(\"L1_MBP supports depth 1 only\") => {\n        // downgrade: resubmit with depth 1\n        let cmd = SubscribeBookDeltas { depth: Some(Depth::new(1)?), ..cmd };\n        client.subscribe_book_deltas(cmd)?;\n    }\n    r => r?,\n}","preventionTips":["Clamp depth to 1 whenever book_type is L1_MBP","Keep per-venue book config tables instead of global depth defaults","Document that L1 on Binance Futures maps to the book-ticker stream"],"tags":["validation","order-book","depth","binance-futures"],"backgroundTag":"value-out-of-range","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"}