nautechsystems/nautilus_trader · error

Unsupported second interval

Error message

Unsupported second interval: {step}s

What it means

The Binance adapter maps Nautilus BarSpecifications to Binance kline intervals, and it only supports a fixed set of step sizes per aggregation. For second-based bars only a 1-second interval exists, so any other Second step throws this error. Binance simply does not offer klines at other sub-minute resolutions.

Solutions

  1. Change the bar spec to Second with step 1, or use Minute aggregation with a supported step
  2. Use the 1-SECOND bar and aggregate/resample to the desired higher resolution in the strategy
  3. Check the supported interval list for the venue before configuring bars
  4. Pick a venue whose adapter supports the desired sub-minute interval if fine granularity is essential

Example fix

// before
let bar_spec = BarSpecification::new(5, BarAggregation::Second, PriceType::Last);
// after
let bar_spec = BarSpecification::new(1, BarAggregation::Second, PriceType::Last); // or Minute/1
Defensive patterns

Strategy: validation

Validate before calling

fn is_supported_bar_spec(spec: &BarSpecification) -> bool {
    matches!(
        (spec.aggregation, spec.step.get()),
        (BarAggregation::Second, 1)
            | (BarAggregation::Minute, 1 | 3 | 5 | 15 | 30)
            | (BarAggregation::Hour, 1 | 2 | 4 | 6 | 8 | 12)
            | (BarAggregation::Day, 1 | 3 | 7 | 14)
    )
}
// assert!(is_supported_bar_spec(&bar_spec), "unsupported bar spec for Binance");

Try / catch

let interval = bar_spec_to_binance_interval(bar_spec)
    .map_err(|e| AdapterError::UnsupportedBarSpec(e.to_string()))?; // surface a typed config error instead of a runtime bail

Prevention

When it happens

Trigger: subscribe_bars / unsubscribe_bars (or bar_spec_to_binance_interval directly) called with a BarSpecification whose aggregation is Second and whose step is anything other than 1 — e.g. a 5-SECOND bar request on a Binance venue.

Common situations: Strategy configs written generically (e.g. 10s bars) and reused across venues; copy-pasting an aggregation spec from another adapter (Bybit/OKX have finer intervals); building bar specs programmatically without checking venue support.

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/c4fe28a20714dd5e. Report an issue: GitHub.

Appendix: source

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

            .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 18893faf8b)