{"record":{"id":"2b360970eed2a621","repo":"nautechsystems/nautilus_trader","slug":"binance-spot-l1-mbp-supports-depth-1-only","errorCode":null,"errorMessage":"Binance Spot L1_MBP supports depth 1 only","messagePattern":"Binance Spot L1_MBP supports depth 1 only","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/data.rs","lineNumber":1816,"sourceCode":"                \"ticker subscription\",\n            );\n        }\n        Ok(())\n    }\n\n    fn subscribe_instruments(&mut self, _cmd: SubscribeInstruments) -> anyhow::Result<()> {\n        log::debug!(\"subscribe_instruments: Binance instruments are fetched via HTTP on connect\");\n        Ok(())\n    }\n\n    fn subscribe_instrument(&mut self, _cmd: SubscribeInstrument) -> anyhow::Result<()> {\n        log::debug!(\"subscribe_instrument: Binance instruments are fetched via HTTP on connect\");\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 Spot 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 Spot 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 Spot supports L1_MBP and L2_MBP order book subscriptions\");\n        }\n        anyhow::ensure!(","sourceCodeStart":1798,"sourceCodeEnd":1834,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/data.rs#L1798-L1834","documentation":"Binance Spot L1_MBP (top-of-book) book-delta subscriptions map to the bookTicker stream, which has no depth dimension. Requesting BookType::L1_MBP together with an explicit depth other than 1 fails this validation; depth None or Some(1) is accepted.","triggerScenarios":"subscribe_book_deltas with book_type = L1_MBP and depth = Some(d) where d != 1 (e.g. 5, 10, 20).","commonSituations":"Venue-agnostic client code that always forwards a configured depth; porting configs from venues that permit L1 with depth; requesting depth 5 expecting a shallow book instead of the top of book.","solutions":["For top-of-book, pass depth None (or Some(1)) with L1_MBP","For deeper books, use L2_MBP with the desired depth (JSON mode maps explicit depths to partial-book streams)"],"exampleFix":"# before\nclient.subscribe_book_deltas(\n    instrument_id,\n    BookType.L1_MBP,\n    depth=5,  # errors: L1 supports depth 1 only\n)\n\n# after\nclient.subscribe_book_deltas(\n    instrument_id,\n    BookType.L1_MBP,\n    depth=None,  # top-of-book via bookTicker\n)","handlingStrategy":"validation","validationCode":"def valid_l1_request(book_type, depth) -> bool:\n    return not (book_type == BookType.L1_MBP and depth is not None and depth != 1)\n\nassert valid_l1_request(book_type, depth), \"L1_MBP allows depth None or 1 only\"","typeGuard":"def valid_l1_request(book_type, depth) -> bool:\n    return not (book_type == BookType.L1_MBP and depth is not None and depth != 1)","tryCatchPattern":null,"preventionTips":["Pass depth=None for L1 subscriptions and only set depth for L2","Validate (book_type, depth) pairs centrally in venue-agnostic client code"],"tags":["binance","spot","order-book","l1-mbp","depth","validation"],"backgroundTag":"invalid-orderbook-depth","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}