{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/data.rs","lineNumber":1832,"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":1814,"sourceCodeEnd":1850,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/data.rs#L1814-L1850","documentation":"When subscribing to L1_MBP (top-of-book) order book data on Binance Spot, an explicit depth other than 1 was requested. L1 book subscription maps to Binance's depth-1 partial book stream, so any depth parameter must be 1 or None.","triggerScenarios":"Calling subscribe_book_deltas with book_type L1_MBP and cmd.depth set to Some(5/10/20/...) on the Binance Spot data client.","commonSituations":"Reusing a subscription config written for L2 depth streams; shared strategy code requesting depth 10/20 while choosing L1 book type; copy-pasted subscription from a Futures/L2 setup.","solutions":["Set depth to None or Depth(1) for L1_MBP subscriptions.","If deeper book data is needed, subscribe with BookType::L2_MBP instead.","Adjust the node/strategy config that builds the SubscribeBookDeltas command."],"exampleFix":"// before\nclient.subscribe_book_deltas(sub_command(BookType::L1_MBP, Some(Depth::new(10))))?;\n// after\nclient.subscribe_book_deltas(sub_command(BookType::L1_MBP, None))?; // or Some(Depth::new(1))","handlingStrategy":"validation","validationCode":"fn validate_l1_depth(book_type: BookType, depth: Option<Depth>) -> Result<(), String> {\n    if book_type == BookType::L1_MBP && depth.map_or(false, |d| d.get() != 1) {\n        Err(\"L1_MBP supports depth 1 only\".into())\n    } else { Ok(()) }\n}","typeGuard":"fn is_valid_l1_request(book_type: BookType, depth: Option<Depth>) -> bool {\n    book_type != BookType::L1_MBP || 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        log::warn!(\"falling back to depth 1\");\n        let cmd = with_depth(cmd, None);\n        client.subscribe_book_deltas(cmd)?;\n    }\n    r => r?,\n}","preventionTips":["Never set depth for L1_MBP subscriptions.","Centralize book subscription construction in one venue-aware helper.","Map desired depth to L2_MBP when depth > 1.","Add config-time validation of book type/depth combos."],"tags":["binance","orderbook","validation","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"}