nautechsystems/nautilus_trader · error

Bybit only supports 1 DAY interval bars

Error message

Bybit only supports 1 DAY interval bars

What it means

Raised by bar_spec_to_bybit_interval when a BarSpec with Day aggregation has a step other than 1; Bybit's kline interval enum has no multi-day values, so only a single-day step can be mapped.

Source

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

            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)
        }
        BarAggregation::Week => {
            if step != 1 {
                anyhow::bail!("Bybit only supports 1 WEEK interval bars");
            }
            Ok(BybitKlineInterval::Week1)
        }
        BarAggregation::Month => {
            if step != 1 {
                anyhow::bail!("Bybit only supports 1 MONTH interval bars");
            }
            Ok(BybitKlineInterval::Month1)
        }
        _ => {
            anyhow::bail!("Bybit does not support {aggregation:?} bars");
        }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the step to 1 DAY.
  2. For 7-day bars use `BarAggregation::Week` step 1 (Bybit supports weekly).
  3. Aggregate multi-day bars locally from daily klines.
  4. Verify the bar spec against `bar_spec_to_bybit_interval` in a unit test before running live.

Example fix

// before
BarSpecification::new(7, BarAggregation::Day, PriceType::Last)
// after
BarSpecification::new(1, BarAggregation::Week, PriceType::Last)
Defensive patterns

Strategy: validation

Validate before calling

fn day_bar_supported(step: u64) -> bool { step == 1 }
anyhow::ensure!(day_bar_supported(bar_spec.step), "Bybit daily bars only support step=1");

Try / catch

match bar_spec_to_bybit_interval(&bar_spec) {
    Ok(interval) => request_klines(interval),
    Err(e) if e.to_string().contains("1 DAY interval") => {
        request_klines(BybitKlineInterval::Day1) // aggregate multi-day bars locally
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Requesting bars with `BarAggregation::Day` and a step other than 1 — e.g. 2-day or 7-day bars.

Common situations: Weekly-ish configs encoded as 7 DAY bars (should be 1 WEEK); multi-day rolling bars from venues that support them; generated specs from a duration in days.

Related errors


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