{"record":{"id":"4aee406f852b9ee3","repo":"nautechsystems/nautilus_trader","slug":"bybit-only-supports-l2-mbp-order-book-deltas","errorCode":null,"errorMessage":"Bybit only supports L2_MBP order book deltas","messagePattern":"Bybit only supports L2_MBP order book deltas","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/data.rs","lineNumber":1016,"sourceCode":"        if self.shutdown_errors.is_empty() {\n            Ok(())\n        } else {\n            let errors = std::mem::take(&mut self.shutdown_errors);\n            anyhow::bail!(\"Bybit data shutdown failed: {}\", errors.join(\"; \"))\n        }\n    }\n\n    fn is_connected(&self) -> bool {\n        self.is_connected.load(Ordering::Relaxed)\n    }\n\n    fn is_disconnected(&self) -> bool {\n        !self.is_connected()\n    }\n\n    fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {\n        if cmd.book_type != BookType::L2_MBP {\n            anyhow::bail!(\"Bybit only supports L2_MBP order book deltas\");\n        }\n\n        let depth = cmd\n            .depth\n            .map_or(BYBIT_DEFAULT_ORDERBOOK_DEPTH, |d| d.get() as u32);\n\n        validate_orderbook_depth(depth)?;\n\n        let instrument_id = cmd.instrument_id;\n        let product_type = self\n            .get_product_type_for_instrument(instrument_id)\n            .unwrap_or(BybitProductType::Linear);\n\n        let ws = self\n            .get_ws_client_for_product(product_type)\n            .context(\"no WebSocket client for product type\")?\n            .clone();\n","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/data.rs#L998-L1034","documentation":"The Bybit adapter only implements L2 market-by-price (L2_MBP) order book delta subscriptions. subscribe_book_deltas rejects any other BookType (e.g. L3_MBO) up front because the exchange does not provide that data model and the adapter has no mapping for it.","triggerScenarios":"Issuing a SubscribeBookDeltas command with cmd.book_type set to something other than BookType::L2_MBP — e.g. configuring L3_MBO book types from another venue's config.","commonSituations":"Reusing a data client config built for venues supporting L3 data; a strategy data spec defaulting to a different book type; copy-pasted subscription code across adapters.","solutions":["Change the subscription to BookType::L2_MBP in your data config/command","If you need L3 data, use a venue that supports it; Bybit does not provide it","Verify the BookType in your strategy's data requests before dispatching to the Bybit client"],"exampleFix":"// before\nlet cmd = SubscribeBookDeltas { book_type: BookType::L3_MBO, .. };\n// after\nlet cmd = SubscribeBookDeltas { book_type: BookType::L2_MBP, .. };","handlingStrategy":"validation","validationCode":"if cmd.book_type != BookType::L2_MBP {\n    return Err(anyhow::anyhow!(\"Bybit requires L2_MBP; got {:?}\", cmd.book_type));\n}","typeGuard":null,"tryCatchPattern":"match client.subscribe_book_deltas(cmd) {\n    Err(e) if e.to_string().contains(\"L2_MBP\") => {\n        log::warn!(\"coercing book type to L2_MBP for Bybit\");\n        client.subscribe_book_deltas(set_book_type(cmd, BookType::L2_MBP))?;\n    }\n    r => r?,\n}","preventionTips":["Always request L2_MBP books from Bybit","Centralize venue-specific book type mapping in config translation","Don't reuse L3-capable venue configs for Bybit"],"tags":["bybit","orderbook","unsupported-feature","book-type"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}