{"record":{"id":"dbbbaf07bc5eaee4","repo":"nautechsystems/nautilus_trader","slug":"deribit-only-supports-l2-mbp-order-book-deltas","errorCode":null,"errorMessage":"Deribit only supports L2_MBP order book deltas","messagePattern":"Deribit only supports L2_MBP order book deltas","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/data.rs","lineNumber":891,"sourceCode":"            .clone();\n\n        log::debug!(\n            \"Subscribing to instrument state for {instrument_id} (channel: {kind}.{currency})\"\n        );\n\n        // Subscribe to broader kind/currency channel (filter in handler)\n        self.spawn_command(async move {\n            if let Err(e) = ws.subscribe_instrument_status(&kind, &currency).await {\n                log::error!(\"Failed to subscribe to instrument status for {instrument_id}: {e}\");\n            }\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!(\"Deribit only supports L2_MBP order book deltas\");\n        }\n\n        let instrument_id = cmd.instrument_id;\n        let needs_load = self.prepare_subscribe(instrument_id)?;\n\n        let ws = self\n            .ws_client\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"WebSocket client not initialized\"))?\n            .clone();\n        let http_client = self.http_client.clone();\n        let instruments = Arc::clone(&self.instruments);\n        let interval = self.get_interval(&cmd.params);\n\n        let depth = cmd\n            .depth\n            .map(|d| d.get() as u32)\n            .or_else(|| {","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/data.rs#L873-L909","documentation":"subscribe_book_deltas rejects the subscription because the requested book type is not L2_MBP; Deribit's order book channel only exposes merged/level-2 data, so L1 or L3 book types cannot be served.","triggerScenarios":"Calling subscribe_book_deltas with a SubscribeBookDeltas command whose book_type is anything other than BookType::L2_MBP (e.g. L3_MBP).","commonSituations":"Reusing a generic subscription builder configured for L3 venues; copying subscription code from a different adapter that supports L3; defaulting book_type incorrectly when constructing data commands programmatically.","solutions":["Set book_type to BookType::L2_MBP on the subscription request","If L3 granularity is required, use a venue that supports it; Deribit cannot serve it","Validate book_type at config/command-construction time before submitting the subscription"],"exampleFix":"// before\nlet cmd = SubscribeBookDeltas { book_type: BookType::L3_MBP, .. };\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!(\"Deribit requires BookType::L2_MBP\"));\n}","typeGuard":"fn is_l2(book_type: BookType) -> bool { matches!(book_type, BookType::L2_MBP) }","tryCatchPattern":"if let Err(e) = client.subscribe_book_deltas(cmd).await {\n    if e.to_string().contains(\"L2_MBP\") { switch_venue_or_downgrade_book_type(); }\n}","preventionTips":["Always construct Deribit book subscriptions with BookType::L2_MBP","Centralize subscription builders per venue instead of sharing book_type config","Validate book_type in strategy config at startup"],"tags":["order-book","subscription","unsupported","rust","deribit"],"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"}