nautechsystems/nautilus_trader · error
Bybit only supports 1 WEEK interval bars
Error message
Bybit only supports 1 WEEK interval bars
What it means
bar_spec_to_bybit_interval converts a nautilus BarSpecification into a Bybit kline interval. Bybit's API only exposes a single weekly kline interval (W), so a Week aggregation with a step other than 1 cannot be mapped and the function bails with this anyhow error. It propagates out of request_bars when requesting weekly historical bars.
Source
Thrown at crates/adapters/bybit/src/common/parse.rs:317
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");
}
}
}
fn default_margin() -> Decimal {
Decimal::new(1, 1)
}View on GitHub (pinned to 18893faf8b)
Solutions
- Change the bar spec step to 1 (1-WEEK bars), which Bybit supports natively
- Request 1-WEEK bars and aggregate multiple weeks into 2-WEEK bars locally in your strategy code
- Request 1-DAY bars and aggregate to multi-week buckets yourself
Example fix
// before let bar_spec = BarSpecification::new(2, BarAggregation::Week, PriceType::Last); // after let bar_spec = BarSpecification::new(1, BarAggregation::Week, PriceType::Last);
Defensive patterns
Strategy: validation
Validate before calling
fn is_supported_bar_spec(spec: &BarSpecification) -> bool {
match spec.aggregation {
BarAggregation::Week => spec.step == 1,
BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Month => true,
_ => false,
}
} Type guard
fn is_bybit_supported_aggregation(a: BarAggregation) -> bool {
matches!(a, BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Week | BarAggregation::Month)
} Try / catch
match bar_spec_to_bybit_interval(&bar_spec) {
Ok(interval) => request(interval),
Err(e) => log::warn!("Bybit bar request rejected: {e}; falling back to 1-DAY bars"),
} Prevention
- Check the adapter's supported interval table before configuring bar specs
- Use step=1 for Week/Month aggregations on Bybit
- Do multi-step aggregation locally instead of expecting exchange support
When it happens
Trigger: Calling request_bars (or DataEngine subscribing via the Bybit adapter) with a BarSpecification whose aggregation is Week and whose step is 2, 3, etc. (e.g. 2-WEEK bars).
Common situations: Configuring a backtest or live data feed with multi-week bar aggregation because another venue supported it; copy-pasting a bar spec like MINUTES/1 changed to WEEKS/2 for downsampling.
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
- Bybit only supports 1 MONTH interval bars
- Bybit does not support {aggregation:?} bars
- Bybit does not support kline/bar data for options
- Derive only supports 1 WEEK interval bars
- Unsupported bar step: {step} with aggregation {:?}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/d2a7dcac3e4dec01.
Report an issue: GitHub.