nautechsystems/nautilus_trader · error

Bybit only supports 1 MONTH interval bars

Error message

Bybit only supports 1 MONTH interval bars

What it means

bar_spec_to_bybit_interval converts a nautilus BarSpecification into a Bybit kline interval. Bybit only offers a single monthly kline interval (M), so a Month aggregation with a step other than 1 has no API mapping and the function bails with this anyhow error.

Source

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

            _ => 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");
        }
    }
}

fn default_margin() -> Decimal {
    Decimal::new(1, 1)
}

/// Parses a spot instrument definition returned by Bybit into a Nautilus currency pair.
///
/// # Panics
///
/// Panics if the constructed instrument fails validation.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set the bar spec step to 1 (1-MONTH bars)
  2. Request 1-MONTH bars and combine them into quarterly buckets in your strategy
  3. Request 1-DAY bars and aggregate locally to the desired monthly multiple

Example fix

// before
let bar_spec = BarSpecification::new(3, BarAggregation::Month, PriceType::Last);
// after
let bar_spec = BarSpecification::new(1, BarAggregation::Month, PriceType::Last);
Defensive patterns

Strategy: validation

Validate before calling

assert!(bar_spec.aggregation != BarAggregation::Month || bar_spec.step == 1, "Bybit only supports 1-MONTH bars");

Try / catch

match bar_spec_to_bybit_interval(&bar_spec) {
    Ok(interval) => request(interval),
    Err(e) => { log::warn!("{e}; requesting 1-MONTH instead"); request(BybitKlineInterval::Month1) }
}

Prevention

When it happens

Trigger: Calling request_bars with a BarSpecification of aggregation Month and step != 1, e.g. 3-MONTH or 6-MONTH bars.

Common situations: Requesting quarterly bars from Bybit history, or reusing a bar spec written for venues that support arbitrary monthly steps.

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/b8933cb948341463. Report an issue: GitHub.