nautechsystems/nautilus_trader · error

Bybit only supports minute intervals 1, 3, 5, 15, 30 (use HO

Error message

Bybit only supports minute intervals 1, 3, 5, 15, 30 (use HOUR for >= 60)

What it means

`bar_spec_to_bybit_interval` maps a bar specification (aggregation + step) to a Bybit kline interval. Bybit only defines 1, 3, 5, 15, and 30 minute klines; any other minute step has no exchange interval, so the mapper fails with this error, suggesting HOUR aggregation for >= 60 minutes.

Source

Thrown at crates/adapters/bybit/src/common/parse.rs:295

/// Converts a Nautilus bar aggregation and step to a Bybit kline interval.
///
/// Bybit supported intervals: 1, 3, 5, 15, 30, 60, 120, 240, 360, 720 (minutes), D, W, M
///
/// # Errors
///
/// Returns an error if the aggregation type or step is not supported by Bybit.
pub fn bar_spec_to_bybit_interval(
    aggregation: BarAggregation,
    step: u64,
) -> anyhow::Result<BybitKlineInterval> {
    match aggregation {
        BarAggregation::Minute => match step {
            1 => Ok(BybitKlineInterval::Minute1),
            3 => Ok(BybitKlineInterval::Minute3),
            5 => Ok(BybitKlineInterval::Minute5),
            15 => Ok(BybitKlineInterval::Minute15),
            30 => Ok(BybitKlineInterval::Minute30),
            _ => anyhow::bail!(
                "Bybit only supports minute intervals 1, 3, 5, 15, 30 (use HOUR for >= 60)"
            ),
        },
        BarAggregation::Hour => match step {
            1 => Ok(BybitKlineInterval::Hour1),
            2 => Ok(BybitKlineInterval::Hour2),
            4 => Ok(BybitKlineInterval::Hour4),
            6 => Ok(BybitKlineInterval::Hour6),
            12 => Ok(BybitKlineInterval::Hour12),
            _ => anyhow::bail!(
                "Bybit only supports the following hour intervals: {BYBIT_HOUR_INTERVALS:?}"
            ),
        },
        BarAggregation::Day => {
            if step != 1 {
                anyhow::bail!("Bybit only supports 1 DAY interval bars");
            }
            Ok(BybitKlineInterval::Day1)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the bar spec step to a supported value: 1, 3, 5, 15, or 30 minutes.
  2. For 60+ minutes, switch aggregation to `Hour` with the corresponding step (e.g. 1 HOUR instead of 60 MINUTE).
  3. Aggregate locally: request 1-minute or 5-minute bars and build composite bars in the strategy.
  4. Check Bybit's kline documentation for the current supported interval list.

Example fix

// before
BarSpecification::new(10, BarAggregation::Minute, PriceType::Last)
// after
BarSpecification::new(15, BarAggregation::Minute, PriceType::Last)
Defensive patterns

Strategy: validation

Validate before calling

const BYBIT_MINUTE_STEPS: [u64; 5] = [1, 3, 5, 15, 30];
fn minute_step_supported(step: u64) -> bool {
    BYBIT_MINUTE_STEPS.contains(&step)
}
anyhow::ensure!(minute_step_supported(bar_spec.step), "unsupported Bybit minute interval");

Try / catch

match bar_spec_to_bybit_interval(&bar_spec) {
    Ok(interval) => request_klines(interval),
    Err(e) if e.to_string().contains("minute intervals") => {
        request_klines(BybitKlineInterval::Minute5) // and aggregate locally
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Requesting bars via `request_bars` with `BarAggregation::Minute` and a step not in {1, 3, 5, 15, 30} — e.g. 2, 10, 45, or 60 minute bars.

Common situations: Configuring a strategy with 10-minute or 45-minute bars copied from another venue (Binance supports 10m) that Bybit does not; generating bar specs programmatically from arbitrary durations.

Related errors


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