{"record":{"id":"f5826610414caec4","repo":"nautechsystems/nautilus_trader","slug":"invalid-depth-depth-supported-depths-deribit","errorCode":null,"errorMessage":"invalid depth {depth}; supported depths: {DERIBIT_BOOK_VALID_DEPTHS:?}","messagePattern":"invalid depth (.+?); supported depths: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/data.rs","lineNumber":918,"sourceCode":"            .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(|| {\n                cmd.params\n                    .as_ref()\n                    .and_then(|p| p.get_u64(\"depth\"))\n                    .map(|n| n as u32)\n            })\n            .unwrap_or(DERIBIT_BOOK_DEFAULT_DEPTH);\n\n        if !DERIBIT_BOOK_VALID_DEPTHS.contains(&depth) {\n            anyhow::bail!(\"invalid depth {depth}; supported depths: {DERIBIT_BOOK_VALID_DEPTHS:?}\");\n        }\n\n        let group = cmd\n            .params\n            .as_ref()\n            .and_then(|p| p.get_str(\"group\"))\n            .unwrap_or(DERIBIT_BOOK_DEFAULT_GROUP)\n            .to_string();\n\n        log::debug!(\n            \"Subscribing to book deltas for {} (group: {}, depth: {}, interval: {}, book_type: {:?})\",\n            instrument_id,\n            group,\n            depth,\n            interval.map_or(\"100ms (default)\".to_string(), |i| i.to_string()),\n            cmd.book_type\n        );\n","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/data.rs#L900-L936","documentation":"Deribit only publishes book snapshots at a fixed set of depths. subscribe_book_deltas reads the optional \"depth\" param (defaulting to DERIBIT_BOOK_DEFAULT_DEPTH) and rejects values not in DERIBIT_BOOK_VALID_DEPTHS.","triggerScenarios":"Calling subscribe_book_deltas with params.depth set to a u64 not contained in DERIBIT_BOOK_VALID_DEPTHS (e.g. depth=5 or depth=2000 when valid depths are like 1, 10, 20, 50, 100, 200, 1000).","commonSituations":"Porting depth values from another exchange adapter; hand-typing a depth that seems reasonable; programmatic depth selection that doesn't snap to the venue's allowed list.","solutions":["Change the \"depth\" param to one of the values in DERIBIT_BOOK_VALID_DEPTHS","Omit the depth param entirely to use DERIBIT_BOOK_DEFAULT_DEPTH","Clamp/snap requested depth to the nearest supported depth before subscribing"],"exampleFix":"// before\nlet params = indexmap! { \"depth\" => 5u64 };\n// after\nlet params = indexmap! { \"depth\" => 10u64 }; // one of DERIBIT_BOOK_VALID_DEPTHS","handlingStrategy":"validation","validationCode":"const VALID: &[u32] = &DERIBIT_BOOK_VALID_DEPTHS;\nif !VALID.contains(&depth) {\n    return Err(anyhow::anyhow!(\"depth {depth} not in {VALID:?}\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.subscribe_book_deltas(cmd).await {\n    if e.to_string().contains(\"invalid depth\") { cmd.params.insert(\"depth\".into(), DERIBIT_BOOK_DEFAULT_DEPTH.into()); retry(); }\n}","preventionTips":["Keep a const list of DERIBIT_BOOK_VALID_DEPTHS in your config layer and snap to nearest","Omit the depth param to use the adapter default","Never copy depth values from other venue adapters"],"tags":["order-book","depth","validation","rust","deribit"],"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-14T00:17:10.932Z"}