nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported second interval: {step}s

Error message

Unsupported second interval: {step}s

What it means

bar_spec_to_binance_interval maps a NautilusTrader BarSpecification onto a native Binance kline interval. For BarAggregation::Second only step 1 is accepted, because the venue offers exactly one second-based interval, '1s', and only on Spot; any other second step bails with this message.

Source

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

            .map(|bar| bar.bar())
            .collect(),
    )
}

/// Converts a Nautilus bar specification to a Binance kline interval.
///
/// # Errors
///
/// Returns an error if the bar specification does not map to a supported
/// Binance kline interval.
pub fn bar_spec_to_binance_interval(
    bar_spec: BarSpecification,
) -> anyhow::Result<BinanceKlineInterval> {
    let step = bar_spec.step.get();
    let interval = match bar_spec.aggregation {
        BarAggregation::Second => match step {
            1 => BinanceKlineInterval::Second1,
            _ => anyhow::bail!("Unsupported second interval: {step}s"),
        },
        BarAggregation::Minute => match step {
            1 => BinanceKlineInterval::Minute1,
            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"),
        },

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Switch to the only supported second interval: 1-SECOND (Spot only).
  2. Use INTERNAL aggregation (e.g. 5-SECOND-LAST-INTERNAL) so NautilusTrader aggregates trade/quote ticks locally instead of requesting a venue interval.
  3. Check the BarType string in config for a wrong step value.

Example fix

// before
// let bar_type = BarType::from("5-SECOND-LAST-EXTERNAL");
// -> Unsupported second interval: 5s

// after: let NautilusTrader aggregate locally from trades
// let bar_type = BarType::from("5-SECOND-LAST-INTERNAL");
Defensive patterns

Strategy: validation

Validate before calling

fn supported_second_step(step: u32) -> bool {
    step == 1 // Binance offers '1s' klines, Spot only
}

Type guard

fn is_supported_second_bar(step: u32) -> bool {
    step == 1
}

Try / catch

let bar_type = BarType::from("5-SECOND-LAST-EXTERNAL");
if let Err(e) = data_client.subscribe_bars(bar_type) {
    if e.to_string().contains("Unsupported second interval") {
        // fall back: 1-SECOND external or 5-SECOND-LAST-INTERNAL
    } else {
        return Err(e);
    }
}

Prevention

When it happens

Trigger: Requesting Binance bars (subscription or historical klines) with a BarType whose specification is 2-SECOND, 5-SECOND, 30-SECOND, etc. — any second step other than 1 — or requesting second bars on a venue/channel that does not carry the 1s interval.

Common situations: A strategy config written for a venue with richer intervals (e.g. 5s klines elsewhere) is pointed at Binance; a BarType string like '5-SECOND-LAST' is copied into config; second aggregation is attempted on futures where 1s klines do not exist.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/c4fe28a20714dd5e. Report an issue: GitHub.