nautechsystems/nautilus_trader · error

Binance Spot supports only the 1s kline interval

Error message

Binance Spot supports only the 1s kline interval

What it means

When mapping a BarType specification to a Binance Spot kline interval, second-based aggregation is only supported with a step of exactly 1 (mapped to Binance's "1s" interval). Any other second step bails, because Binance Spot offers no 2s/5s/... kline intervals.

Source

Thrown at crates/adapters/binance/src/spot/http/client.rs:2979

    /// or the request fails.
    pub async fn request_binance_bars(
        &self,
        bar_type: BarType,
        start: Option<Timestamp>,
        end: Option<Timestamp>,
        limit: Option<u32>,
    ) -> anyhow::Result<Vec<crate::common::bar::BinanceBar>> {
        anyhow::ensure!(
            bar_type.aggregation_source() == AggregationSource::External,
            "Only EXTERNAL aggregation is supported"
        );

        let spec = bar_type.spec();
        let step = spec.step.get();
        let interval = match spec.aggregation {
            BarAggregation::Second if step == 1 => "1s".to_string(),
            BarAggregation::Second => {
                anyhow::bail!("Binance Spot supports only the 1s kline interval")
            }
            BarAggregation::Minute => format!("{step}m"),
            BarAggregation::Hour => format!("{step}h"),
            BarAggregation::Day => format!("{step}d"),
            BarAggregation::Week => format!("{step}w"),
            BarAggregation::Month => format!("{step}M"),
            a => anyhow::bail!("Binance does not support {a:?} aggregation"),
        };

        let instrument_id = bar_type.instrument_id();
        let symbol = instrument_id.symbol;
        let instrument = self.instrument_from_cache_by_id(instrument_id)?;
        let klines = self
            .inner
            .klines(
                symbol.as_str(),
                &interval,
                start.map(|dt| dt.as_millisecond()),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use SECOND[1] bars and aggregate to higher steps locally in the strategy
  2. Switch the bar spec to Minute aggregation (e.g. MINUTE[1]) which Binance Spot supports natively
  3. Adjust the BarType in the data subscription/request config to a supported interval

Example fix

// before
let bar_type = BarType::from_str("BTCUSDT.BINANCE-SECOND-5-INTERNAL")?;
// after
let bar_type = BarType::from_str("BTCUSDT.BINANCE-SECOND-1-INTERNAL")?;
Defensive patterns

Strategy: validation

Validate before calling

if bar_type.aggregation() == BarAggregation::Second && bar_type.spec().step.get() != 1 {
    return Err("Binance Spot requires SECOND[1]");
}

Prevention

When it happens

Trigger: Calling the Spot kline request path (bar request/load via the HTTP client) with a BarAggregation::Second whose spec step is not 1, e.g. SECOND[5] or SECOND[15] bars.

Common situations: Configuring a strategy on sub-minute bars with step > 1 assuming arbitrary second bars are supported; bar specs generated programmatically from configs that aggregate seconds.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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