nautechsystems/nautilus_trader · error

Unsupported hour step for Kraken Futures

Error message

Unsupported hour step for Kraken Futures: {step}

What it means

bar_type_to_futures_resolution cannot map the requested Hour-aggregation step for Kraken Futures; the futures resolution strings only cover 1h, 4h, and 12h, so any other hour step has no API resolution and the conversion fails.

Solutions

  1. Change the hour step to 1, 4, or 12.
  2. Request 1h bars and aggregate locally into 2h/6h/etc. bars.
  3. Use Day aggregation (step 1) instead of 24h bars.

Example fix

// before
BarSpec::new(BarAggregation::Hour, 2)
// after
BarSpec::new(BarAggregation::Hour, 1) // aggregate to 2h locally
Defensive patterns

Strategy: validation

Validate before calling

const FUTURES_HOUR_STEPS: [u32; 3] = [1, 4, 12];
if bar_type.spec().aggregation == BarAggregation::Hour
    && !FUTURES_HOUR_STEPS.contains(&bar_type.spec().step.get() as u32) {
    eprintln!("Kraken Futures hour steps: 1, 4, 12");
}

Try / catch

match bar_type_to_futures_resolution(&bar_type) {
    Ok("1h") => {},
    Err(e) if e.to_string().contains("hour step") => switch_to_1h_and_aggregate(&bar_type)?,
    res => res?,
}

Prevention

When it happens

Trigger: bar_type_to_futures_resolution receives BarAggregation::Hour with step not in {1, 4, 12} — e.g. 2h, 6h, or 24h bars.

Common situations: Bar specs copied from venues supporting arbitrary hour steps (e.g. Binance 2h/8h); multi-venue strategies not per-venue specializing bar specs.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

/// # 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 {
            1 => Ok("1m"),
            5 => Ok("5m"),
            15 => Ok("15m"),
            _ => anyhow::bail!("Unsupported minute step for Kraken Futures: {step}"),
        },
        BarAggregation::Hour => match step {
            1 => Ok("1h"),
            4 => Ok("4h"),
            12 => Ok("12h"),
            _ => anyhow::bail!("Unsupported hour step for Kraken Futures: {step}"),
        },
        BarAggregation::Day => {
            if step == 1 {
                Ok("1d")
            } else {
                anyhow::bail!("Unsupported day step for Kraken Futures: {step}")
            }
        }
        BarAggregation::Week => {
            if step == 1 {
                Ok("1w")
            } else {
                anyhow::bail!("Unsupported week step for Kraken Futures: {step}")
            }
        }
        other => {
            anyhow::bail!("Unsupported bar aggregation for Kraken Futures: {other:?}");
        }

View on GitHub (pinned to 18893faf8b)