nautechsystems/nautilus_trader · error

Unsupported bar aggregation for Kraken Spot: {other:?}

Error message

Unsupported bar aggregation for Kraken Spot: {other:?}

What it means

Kraken Spot OHLC data only supports Minute, Hour, and Day bar aggregations; these map to Kraken's interval (1, 60, 1440) multiplied by the bar step. Any other BarAggregation (Tick, Volume, Second, Week, Month, etc.) is rejected by bar_type_to_spot_interval.

Source

Thrown at crates/adapters/kraken/src/common/parse.rs:1177

        avg_px_open,
    })
}

/// Converts a Nautilus BarType to Kraken Spot API interval (in minutes).
///
/// # Errors
///
/// Returns an error if:
/// - Bar aggregation type is not supported (only Minute, Hour, Day are valid).
/// - Bar step is not supported for the aggregation type.
pub fn bar_type_to_spot_interval(bar_type: BarType) -> anyhow::Result<u32> {
    let step = bar_type.spec().step.get() as u32;
    let base_interval = match bar_type.spec().aggregation {
        BarAggregation::Minute => 1,
        BarAggregation::Hour => 60,
        BarAggregation::Day => 1440,
        other => {
            anyhow::bail!("Unsupported bar aggregation for Kraken Spot: {other:?}");
        }
    };
    Ok(base_interval * step)
}

/// Converts a Nautilus BarType to Kraken Futures API resolution string.
///
/// Supported resolutions: 1m, 5m, 15m, 1h, 4h, 12h, 1d, 1w
///
/// # Errors
///
/// Returns an error if:
/// - Bar aggregation type is not supported.
/// - Bar step is not supported for the aggregation type.
pub fn bar_type_to_futures_resolution(bar_type: BarType) -> anyhow::Result<&'static str> {
    let step = bar_type.spec().step.get() as u32;
    match bar_type.spec().aggregation {
        BarAggregation::Minute => match step {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Request Minute, Hour, or Day bars only, adjusting the step (step multiplies the base interval).
  2. Aggregate finer/different data client-side (e.g. request 1-minute bars and aggregate to seconds/volume locally).
  3. Switch the bar spec: e.g. Minute with step 5 for 5m bars instead of unsupported aggregations.

Example fix

// before
let bar_type = BarType::new(instrument_id, BarSpec::new(BarAggregation::Second, 30));
// after
let bar_type = BarType::new(instrument_id, BarSpec::new(BarAggregation::Minute, 1));
Defensive patterns

Strategy: validation

Validate before calling

const SPOT_AGGREGATIONS: [BarAggregation; 3] =
    [BarAggregation::Minute, BarAggregation::Hour, BarAggregation::Day];
if !SPOT_AGGREGATIONS.contains(&bar_type.spec().aggregation) {
    eprintln!("Kraken Spot supports only Minute/Hour/Day bars");
}

Try / catch

match bar_type_to_spot_interval(&bar_type) {
    Ok(interval) => request_bars(interval),
    Err(e) if e.to_string().contains("Unsupported bar aggregation") => {
        fallback_to_1m_and_aggregate(&bar_type)?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: request_bars calls bar_type_to_spot_interval with a BarType whose spec aggregation is not Minute, Hour, or Day — e.g. second-based bars or volume bars on a Kraken Spot venue.

Common situations: Configuring bar aggregations generically across venues without checking Kraken Spot's supported intervals; requesting 1-second or tick bars from historical data endpoints.

Related errors


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