nautechsystems/nautilus_trader · error

Unsupported day interval

Error message

Unsupported day interval: {step}d

What it means

This error is raised by bar_spec_to_binance_interval when a Day-aggregated bar spec uses a step other than 1 or 3, the only daily klines Binance offers (1d, 3d). The conversion cannot proceed and subscription fails.

Solutions

  1. Use step 1 or 3 for day bars
  2. Express the desired period as a supported interval (7 days = 1 week, 30 days = 1 month)
  3. Aggregate 1d bars internally to synthesize other day multiples

Example fix

// before
BarSpec::new(instrument_id, BAR_SPEC_2_DAY, PriceType::Last)
// after
BarSpec::new(instrument_id, BAR_SPEC_1_DAY, PriceType::Last)
Defensive patterns

Strategy: validation

Validate before calling

fn is_supported_day_step(step: u64) -> bool { matches!(step, 1 | 3) }
assert!(is_supported_day_step(bar_spec.aggregation_step), "Binance day bars must be 1d or 3d");

Type guard

fn is_supported_day_step(step: u64) -> bool { matches!(step, 1 | 3) }

Try / catch

match client.subscribe_bars(bar_spec) {
    Err(e) if e.to_string().contains("Unsupported day interval") => {
        log::warn!("using 1d bars instead");
    }
    r => r?,
}

Prevention

When it happens

Trigger: subscribe_bars or unsubscribe_bars with BarAggregation::Day and step not in {1,3}, e.g. a 2-DAY or 7-DAY bar spec.

Common situations: Weekly-equivalent requests expressed as 7-DAY bars instead of 1-WEEK; copy-pasted bar specs from other exchanges that support arbitrary day counts.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/common/parse.rs:1453

            3 => BinanceKlineInterval::Minute3,
            5 => BinanceKlineInterval::Minute5,
            15 => BinanceKlineInterval::Minute15,
            30 => BinanceKlineInterval::Minute30,
            _ => anyhow::bail!("Unsupported minute interval: {step}m"),
        },
        BarAggregation::Hour => match step {
            1 => BinanceKlineInterval::Hour1,
            2 => BinanceKlineInterval::Hour2,
            4 => BinanceKlineInterval::Hour4,
            6 => BinanceKlineInterval::Hour6,
            8 => BinanceKlineInterval::Hour8,
            12 => BinanceKlineInterval::Hour12,
            _ => anyhow::bail!("Unsupported hour interval: {step}h"),
        },
        BarAggregation::Day => match step {
            1 => BinanceKlineInterval::Day1,
            3 => BinanceKlineInterval::Day3,
            _ => anyhow::bail!("Unsupported day interval: {step}d"),
        },
        BarAggregation::Week => match step {
            1 => BinanceKlineInterval::Week1,
            _ => anyhow::bail!("Unsupported week interval: {step}w"),
        },
        BarAggregation::Month => match step {
            1 => BinanceKlineInterval::Month1,
            _ => anyhow::bail!("Unsupported month interval: {step}M"),
        },
        agg => anyhow::bail!("Unsupported bar aggregation for Binance: {agg:?}"),
    };

    Ok(interval)
}

pub(crate) fn quote_to_l1_deltas(quote: QuoteTick, sequence: u64) -> OrderBookDeltas {
    let bid_action = if quote.bid_size.is_zero() {
        BookAction::Delete

View on GitHub (pinned to 18893faf8b)