nautechsystems/nautilus_trader · error

Derive only supports 1 DAY interval bars

Error message

Derive only supports 1 DAY interval bars

What it means

bar_spec_to_derive_period cannot convert a Day-aggregation bar spec whose step is not 1; Derive's candle API accepts period values in seconds and only supports a single 86400-second (1 day) period, so multi-day steps are unmappable.

Source

Thrown at crates/adapters/derive/src/websocket/parse.rs:668

    match aggregation {
        BarAggregation::Minute => match step {
            1 => Ok(60),
            5 => Ok(300),
            15 => Ok(900),
            30 => Ok(1800),
            _ => anyhow::bail!(
                "Derive only supports minute intervals 1, 5, 15, 30 (use HOUR for >= 60)"
            ),
        },
        BarAggregation::Hour => match step {
            1 => Ok(3600),
            4 => Ok(14400),
            8 => Ok(28800),
            _ => anyhow::bail!("Derive only supports hour intervals 1, 4, 8"),
        },
        BarAggregation::Day => {
            if step != 1 {
                anyhow::bail!("Derive only supports 1 DAY interval bars");
            }
            Ok(86400)
        }
        BarAggregation::Week => {
            if step != 1 {
                anyhow::bail!("Derive only supports 1 WEEK interval bars");
            }
            Ok(604800)
        }
        _ => anyhow::bail!("Derive does not support {aggregation:?} bars"),
    }
}

fn timestamp_seconds_to_nanos(value: u64, field: &str) -> anyhow::Result<UnixNanos> {
    let nanos = value
        .checked_mul(NANOSECONDS_IN_SECOND)
        .with_context(|| format!("Derive {field} overflows nanoseconds"))?;
    Ok(UnixNanos::from(nanos))

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use BarAggregation::Day with step 1 only
  2. For weekly bars aggregate 1-day bars client-side in the strategy
  3. Use the Week aggregation if supported (step 1) instead of Day/7
  4. Adjust the BarSpecification in the bar request

Example fix

// before
BarAggregation::Day, step: 7
// after
BarAggregation::Day, step: 1 // aggregate weekly downstream
Defensive patterns

Strategy: validation

Validate before calling

if agg == BarAggregation::Day && step != 1 {
    return Err("Derive supports only Day step 1; aggregate weekly client-side".into());
}

Try / catch

match bar_spec_to_derive_period(&BarAggregation::Day, step) {
    Ok(p) => subscribe(p),
    Err(e) if e.to_string().contains("1 DAY interval") => {
        // build multi-day bars from daily candles in strategy code
        subscribe(bar_spec_to_derive_period(&BarAggregation::Day, 1)?)
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Requesting bars with BarAggregation::Day and step != 1 (e.g. Day/7) via request_bars or bar config.

Common situations: Weekly/monthly bar configs ported from other venues that support multi-day candles.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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