nautechsystems/nautilus_trader · error
DeribitBookSummary requests require metadata['currency']
Error message
DeribitBookSummary requests require metadata['currency']
What it means
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.
Source
Thrown at crates/adapters/deribit/src/data.rs:497
}
fn subscribe_combo_legs(params: &Option<Params>) -> bool {
params
.as_ref()
.and_then(|params| params.get_bool("subscribe_combo_legs"))
.unwrap_or(false)
}
fn book_summary_metadata_currency(data_type: &DataType) -> anyhow::Result<String> {
data_type
.metadata()
.and_then(|m| m.get("currency"))
.and_then(|v| v.as_str())
.map(str::trim)
.filter(|value| !value.is_empty())
.map(str::to_ascii_uppercase)
.ok_or_else(|| {
anyhow::anyhow!("DeribitBookSummary requests require metadata['currency']")
})
}
fn book_summary_metadata_kind(data_type: &DataType) -> Option<String> {
data_type
.metadata()
.and_then(|m| m.get("kind"))
.and_then(|v| v.as_str())
.map(str::trim)
.filter(|value| !value.is_empty())
.map(str::to_ascii_lowercase)
}
fn book_summary_data_type(currency: &str, kind: Option<&str>) -> DataType {
let mut metadata = Params::new();
metadata.insert(
"currency".to_string(),
serde_json::Value::String(currency.to_string()),View on GitHub (pinned to 18893faf8b)
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.
Example fix
// before
let data_type = DataType::new(DeribitBookSummary::default(), None);
data_engine.subscribe(&data_type)?;
// after
let data_type = DataType::new(DeribitBookSummary::default(), Some(indexmap! { "currency" => "BTC" }));
data_engine.subscribe(&data_type)?; Defensive patterns
Strategy: validation
Validate before calling
// Rust
let currency = metadata
.as_ref()
.and_then(|m| m.get("currency"))
.and_then(|v| v.as_str())
.map(str::trim)
.filter(|s| !s.is_empty());
anyhow::ensure!(currency.is_some(), "DeribitBookSummary requires metadata['currency']"); Type guard
fn has_currency(data_type: &DataType) -> bool {
data_type
.metadata()
.as_ref()
.and_then(|m| m.get("currency"))
.and_then(|v| v.as_str())
.map(|s| !s.trim().is_empty())
.unwrap_or(false)
} Try / catch
match book_summary_metadata_currency(&data_type) {
Ok(ccy) => subscribe_book_summaries(ccy).await?,
Err(e) => return Err(anyhow!("fix subscription metadata: {e}")),
} Prevention
- 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
When it happens
Trigger: 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"}.
Common situations: 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").
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Instrument {instrument_id} not found and `auto_load_missing_
- Deribit only supports L2_MBP order book deltas
- Deribit only supports L2_MBP order book depth
- InstrumentState channel requires kind and currency parameter
- custom data request requires `instrument_id` metadata
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/0404fbb74d9ddf85.
Report an issue: GitHub.