nautechsystems/nautilus_trader · error

Deribit does not support {a:?} aggregation

Error message

Deribit does not support {a:?} aggregation

What it means

request_bars maps a nautilus BarAggregation to a Deribit resolution string; only Minute, Hour, and Day aggregations are supported. Any other aggregation (e.g. Second, Week, Tick, Volume) bails with 'Deribit does not support {aggregation}'.

Source

Thrown at crates/adapters/deribit/src/http/client.rs:1396

        let now = Timestamp::now();

        // Default to last hour if no start/end provided
        let end_dt = end.unwrap_or(now);
        let start_dt = start.unwrap_or(end_dt - jiff::SignedDuration::from_hours(1));

        if let (Some(s), Some(e)) = (start, end) {
            anyhow::ensure!(s < e, "Invalid time range: start={s:?} end={e:?}");
        }

        // Convert BarType to Deribit resolution
        let spec = bar_type.spec();
        let step = spec.step.get();
        let resolution = match spec.aggregation {
            BarAggregation::Minute => format!("{step}"),
            BarAggregation::Hour => format!("{}", step * 60),
            BarAggregation::Day => "1D".to_string(),
            a => anyhow::bail!("Deribit does not support {a:?} aggregation"),
        };

        // Validate resolution is supported by Deribit
        let supported_resolutions = [
            "1", "3", "5", "10", "15", "30", "60", "120", "180", "360", "720", "1D",
        ];

        if !supported_resolutions.contains(&resolution.as_str()) {
            anyhow::bail!(
                "Deribit does not support resolution '{resolution}'. Supported: {supported_resolutions:?}"
            );
        }

        let instrument_id = bar_type.instrument_id();
        let (price_precision, size_precision, use_cost_for_volume) =
            if let Some(instrument) = self.get_instrument(&instrument_id.symbol.inner()) {
                (
                    instrument.price_precision(),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use only Minute, Hour, or Day aggregations for Deribit bar requests
  2. Build second/tick-level granularity manually from trades if needed
  3. Validate bar_type.spec().aggregation before issuing the request

Example fix

// before
let bar_type = BarType::new(instrument_id, BarAggregation::Second(10).into(), PriceType::Last);
let bars = client.request_bars(bar_type).await?; // bails
// after
let bar_type = BarType::new(instrument_id, BarAggregation::Minute(1).into(), PriceType::Last);
assert!(matches!(bar_type.spec().aggregation, BarAggregation::Minute(_) | BarAggregation::Hour(_) | BarAggregation::Day(_)));
let bars = client.request_bars(bar_type).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn supports_deribit_aggregation(spec: &BarSpecification) -> bool {
    matches!(spec.aggregation, BarAggregation::Minute(_) | BarAggregation::Hour(_) | BarAggregation::Day(_))
}

Type guard

fn is_deribit_bar_type(bar_type: &BarType) -> bool {
    matches!(bar_type.spec().aggregation,
        BarAggregation::Minute(_) | BarAggregation::Hour(_) | BarAggregation::Day(_))
}

Prevention

When it happens

Trigger: Requesting bars with a BarType whose spec.aggregation is anything other than Minute, Hour, or Day — e.g. Second/Tick/Volume aggregations or Weekly bars.

Common situations: Configuring a data request with Second-aggregated bars assuming all venues support them; generic strategy code reusing bar specs across venues; requesting WEEK aggregations naively.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/58226a31f3aa62ec. Report an issue: GitHub.