{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":1915,"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":1897,"sourceCodeEnd":1933,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/data.rs#L1897-L1933","documentation":"An L1_MBP book-deltas subscription maps to Binance's top-of-book (bookTicker-style) stream, which has no configurable depth. The adapter accepts `depth: None` or a depth of exactly 1; any other positive depth is rejected before the subscription is registered in `l1_book_subscriptions`, because Binance cannot honour a deeper book over the L1 stream.","triggerScenarios":"`subscribe_book_deltas` / `subscribe_order_book_deltas` with `book_type=BookType.L1_MBP` and `depth` set to any value other than 1 (e.g. PositiveU16 of 5, 10, 100). Passing depth=None or omitting it is fine.","commonSituations":"Porting an existing L2_MBP config to L1 and leaving the depth parameter in place; generic subscription code that always forwards a depth; assuming depth is silently ignored for L1.","solutions":["Pass depth=None (or depth=1) for L1_MBP subscriptions","If you actually need a deeper book, subscribe with BookType.L2_MBP and one of the valid depths [5, 10, 20, 50, 100, 500, 1000]"],"exampleFix":"# before\nactor.subscribe_order_book_deltas(instrument_id, book_type=BookType.L1_MBP, depth=10)\n\n# after\nactor.subscribe_order_book_deltas(instrument_id, book_type=BookType.L1_MBP, depth=None)\n# need depth? use L2: book_type=BookType.L2_MBP, depth=10","handlingStrategy":"validation","validationCode":"def validate_l1_depth(depth) -> None:\n    if depth is not None and depth != 1:\n        raise ValueError('Binance Futures L1_MBP supports depth None or 1 only — pass depth=None')\n\nvalidate_l1_depth(depth)\nactor.subscribe_order_book_deltas(instrument_id, book_type=BookType.L1_MBP, depth=None)","typeGuard":"def is_valid_l1_depth(depth) -> bool:\n    return depth is None or depth == 1","tryCatchPattern":"try:\n    actor.subscribe_order_book_deltas(instrument_id, book_type=BookType.L1_MBP, depth=depth)\nexcept Exception as e:\n    if 'L1_MBP supports depth 1 only' in str(e):\n        raise ValueError('Retrying with depth=None for the L1 top-of-book stream') from e\n    raise","preventionTips":["Never forward a depth parameter to L1 subscriptions — top-of-book has no depth by definition","Centralise book subscription config; validate depth only for L2_MBP"],"tags":["binance","futures","orderbook","l1-mbp","depth"],"backgroundTag":"invalid-orderbook-depth","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}