{"record":{"id":"0404fbb74d9ddf85","repo":"nautechsystems/nautilus_trader","slug":"deribitbooksummary-requests-require-metadata-curr","errorCode":null,"errorMessage":"DeribitBookSummary requests require metadata['currency']","messagePattern":"DeribitBookSummary requests require metadata\\['currency'\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/data.rs","lineNumber":497,"sourceCode":"    }\n\n    fn subscribe_combo_legs(params: &Option<Params>) -> bool {\n        params\n            .as_ref()\n            .and_then(|params| params.get_bool(\"subscribe_combo_legs\"))\n            .unwrap_or(false)\n    }\n\n    fn book_summary_metadata_currency(data_type: &DataType) -> anyhow::Result<String> {\n        data_type\n            .metadata()\n            .and_then(|m| m.get(\"currency\"))\n            .and_then(|v| v.as_str())\n            .map(str::trim)\n            .filter(|value| !value.is_empty())\n            .map(str::to_ascii_uppercase)\n            .ok_or_else(|| {\n                anyhow::anyhow!(\"DeribitBookSummary requests require metadata['currency']\")\n            })\n    }\n\n    fn book_summary_metadata_kind(data_type: &DataType) -> Option<String> {\n        data_type\n            .metadata()\n            .and_then(|m| m.get(\"kind\"))\n            .and_then(|v| v.as_str())\n            .map(str::trim)\n            .filter(|value| !value.is_empty())\n            .map(str::to_ascii_lowercase)\n    }\n\n    fn book_summary_data_type(currency: &str, kind: Option<&str>) -> DataType {\n        let mut metadata = Params::new();\n        metadata.insert(\n            \"currency\".to_string(),\n            serde_json::Value::String(currency.to_string()),","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/data.rs#L479-L515","documentation":"Subscribing to DeribitBookSummary data requires the request metadata to specify the currency (e.g. BTC, ETH) because the underlying ticker.book_summary channels are per currency/kind. book_summary_metadata_currency extracts metadata[\"currency\"], trims/uppercases it, and raises this error when the metadata is missing, empty, or whitespace-only.","triggerScenarios":"Requesting BookSummary data via the DataEngine with a DataType whose metadata dict lacks a \"currency\" key, contains an empty string, or only whitespace — e.g. subscribing to DeribitBookSummary(None) without passing metadata={\"currency\": \"BTC\"}.","commonSituations":"Copy-pasting a subscribe call for another Deribit data type that doesn't require currency; building the DataType programmatically and forgetting the metadata dict; typos in the key name (\"Currency\", \"curr\").","solutions":["Pass metadata={\"currency\": \"BTC\"} (uppercase, e.g. BTC/ETH/SOL/USDC) when requesting DeribitBookSummary data.","Verify the key is exactly \"currency\" and non-empty after trimming.","If currency should be derived, set it from the instrument's venue/currency before subscribing."],"exampleFix":"// before\nlet data_type = DataType::new(DeribitBookSummary::default(), None);\ndata_engine.subscribe(&data_type)?;\n\n// after\nlet data_type = DataType::new(DeribitBookSummary::default(), Some(indexmap! { \"currency\" => \"BTC\" }));\ndata_engine.subscribe(&data_type)?;","handlingStrategy":"validation","validationCode":"// Rust\nlet currency = metadata\n    .as_ref()\n    .and_then(|m| m.get(\"currency\"))\n    .and_then(|v| v.as_str())\n    .map(str::trim)\n    .filter(|s| !s.is_empty());\nanyhow::ensure!(currency.is_some(), \"DeribitBookSummary requires metadata['currency']\");","typeGuard":"fn has_currency(data_type: &DataType) -> bool {\n    data_type\n        .metadata()\n        .as_ref()\n        .and_then(|m| m.get(\"currency\"))\n        .and_then(|v| v.as_str())\n        .map(|s| !s.trim().is_empty())\n        .unwrap_or(false)\n}","tryCatchPattern":"match book_summary_metadata_currency(&data_type) {\n    Ok(ccy) => subscribe_book_summaries(ccy).await?,\n    Err(e) => return Err(anyhow!(\"fix subscription metadata: {e}\")),\n}","preventionTips":["Always pass metadata={\"currency\": \"<CCY>\"} with BookSummary subscriptions","Use uppercase currency codes exactly as Deribit expects","Centralize DataType construction for Deribit in one helper that injects currency"],"tags":["deribit","rust","subscription","metadata"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}