nautechsystems/nautilus_trader · error

Unsupported week interval

Error message

Unsupported week interval: {step}w

What it means

Binance offers only a single weekly kline (1w). bar_spec_to_binance_interval raises this error for any Week-aggregated bar spec whose step is not 1, refusing to subscribe to an interval the exchange cannot serve.

Solutions

  1. Change the bar spec to 1-WEEK
  2. Aggregate 1w bars internally (or aggregate 1d bars) to build 2-week bars
  3. Pull longer timeframes from historical/data-vendor sources instead of Binance klines

Example fix

// before
BarSpec::new(instrument_id, BAR_SPEC_2_WEEK, PriceType::Last)
// after
BarSpec::new(instrument_id, BAR_SPEC_1_WEEK, PriceType::Last)
Defensive patterns

Strategy: validation

Validate before calling

fn is_supported_week_step(step: u64) -> bool { step == 1 }
assert!(is_supported_week_step(bar_spec.aggregation_step), "Binance supports only 1w bars");

Type guard

fn is_supported_week_step(step: u64) -> bool { step == 1 }

Try / catch

match client.subscribe_bars(bar_spec) {
    Err(e) if e.to_string().contains("Unsupported week interval") => {
        log::warn!("subscribing 1w and aggregating multi-week bars internally");
    }
    r => r?,
}

Prevention

When it happens

Trigger: subscribe_bars or unsubscribe_bars with BarAggregation::Week and step != 1, e.g. a 2-WEEK bar spec.

Common situations: Requesting bi-weekly or multi-week bars directly from Binance klines, usually to align a strategy with a longer-term timeframe.

Related errors


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

Appendix: source

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

            _ => 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
    } else {
        BookAction::Update
    };
    let ask_action = if quote.ask_size.is_zero() {

View on GitHub (pinned to 18893faf8b)