{"record":{"id":"7369a724fcd55ccd","repo":"nautechsystems/nautilus_trader","slug":"dydx-only-supports-l2-mbp-order-book-deltas-recei","errorCode":null,"errorMessage":"dYdX only supports L2_MBP order book deltas, received {:?}","messagePattern":"dYdX only supports L2_MBP order book deltas, received (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/data.rs","lineNumber":518,"sourceCode":"    fn subscribe_instrument(&mut self, cmd: SubscribeInstrument) -> anyhow::Result<()> {\n        if let Some(instrument) = self.instrument_cache.get(&cmd.instrument_id) {\n            log::debug!(\"Sending cached instrument for {}\", cmd.instrument_id);\n            if let Err(e) = self.data_sender.send(DataEvent::Instrument(instrument)) {\n                log::warn!(\"Failed to send instrument {}: {e}\", cmd.instrument_id);\n            }\n        } else {\n            log::warn!(\n                \"Instrument {} not found in cache (available: {})\",\n                cmd.instrument_id,\n                self.instrument_cache.len()\n            );\n        }\n        Ok(())\n    }\n\n    fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {\n        if cmd.book_type != BookType::L2_MBP {\n            anyhow::bail!(\n                \"dYdX only supports L2_MBP order book deltas, received {:?}\",\n                cmd.book_type\n            );\n        }\n\n        self.ensure_order_book(cmd.instrument_id, BookType::L2_MBP);\n        self.active_delta_subs.insert(cmd.instrument_id);\n\n        let ws = self.ws_client.clone();\n        let instrument_id = cmd.instrument_id;\n\n        self.spawn_ws(\n            async move {\n                ws.subscribe_orderbook(instrument_id)\n                    .await\n                    .context(\"orderbook subscription\")\n            },\n            \"dYdX orderbook subscription\",","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/data.rs#L500-L536","documentation":"dYdX's WebSocket order book stream provides only depth-2 market-by-price (L2_MBP) data. subscribe_book_deltas validates the requested BookType and bails if the client asks for L3_MBP, ensuring the adapter never subscribes to a book depth the exchange cannot deliver.","triggerScenarios":"Subscribing to order book deltas for a dYdX instrument with a SubscriptionBookType/book_type other than BookType::L2_MBP (e.g. L3_MBP).","commonSituations":"Copying an order book subscription config from a venue that supports L3 depth; a config file specifying full-depth books for all venues.","solutions":["Set the book type to L2_MBP for dYdX order book subscriptions","Remove L3 book subscriptions for dYdX instruments","Use a different data source if L3 depth is required"],"exampleFix":"// before\nlet cmd = SubscribeBookDeltas { book_type: BookType::L3_MBP, .. };\n// after\nlet cmd = SubscribeBookDeltas { book_type: BookType::L2_MBP, .. };","handlingStrategy":"validation","validationCode":"if book_type != BookType::L2_MBP {\n    return Err(format!(\"dYdX requires L2_MBP, got {book_type:?}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use BookType::L2_MBP for dYdX order book subscriptions","Validate book depth settings per venue in config loading"],"tags":["rust","orderbook","dydx-exchange","unsupported-feature"],"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"}