{"record":{"id":"d2a7dcac3e4dec01","repo":"nautechsystems/nautilus_trader","slug":"bybit-only-supports-1-week-interval-bars","errorCode":null,"errorMessage":"Bybit only supports 1 WEEK interval bars","messagePattern":"Bybit only supports 1 WEEK interval bars","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":317,"sourceCode":"        BarAggregation::Hour => match step {\n            1 => Ok(BybitKlineInterval::Hour1),\n            2 => Ok(BybitKlineInterval::Hour2),\n            4 => Ok(BybitKlineInterval::Hour4),\n            6 => Ok(BybitKlineInterval::Hour6),\n            12 => Ok(BybitKlineInterval::Hour12),\n            _ => anyhow::bail!(\n                \"Bybit only supports the following hour intervals: {BYBIT_HOUR_INTERVALS:?}\"\n            ),\n        },\n        BarAggregation::Day => {\n            if step != 1 {\n                anyhow::bail!(\"Bybit only supports 1 DAY interval bars\");\n            }\n            Ok(BybitKlineInterval::Day1)\n        }\n        BarAggregation::Week => {\n            if step != 1 {\n                anyhow::bail!(\"Bybit only supports 1 WEEK interval bars\");\n            }\n            Ok(BybitKlineInterval::Week1)\n        }\n        BarAggregation::Month => {\n            if step != 1 {\n                anyhow::bail!(\"Bybit only supports 1 MONTH interval bars\");\n            }\n            Ok(BybitKlineInterval::Month1)\n        }\n        _ => {\n            anyhow::bail!(\"Bybit does not support {aggregation:?} bars\");\n        }\n    }\n}\n\nfn default_margin() -> Decimal {\n    Decimal::new(1, 1)\n}","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L299-L335","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nlet bar_spec = BarSpecification::new(2, BarAggregation::Week, PriceType::Last);\n// after\nlet bar_spec = BarSpecification::new(1, BarAggregation::Week, PriceType::Last);","handlingStrategy":"validation","validationCode":"fn is_supported_bar_spec(spec: &BarSpecification) -> bool {\n    match spec.aggregation {\n        BarAggregation::Week => spec.step == 1,\n        BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Month => true,\n        _ => false,\n    }\n}","typeGuard":"fn is_bybit_supported_aggregation(a: BarAggregation) -> bool {\n    matches!(a, BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Week | BarAggregation::Month)\n}","tryCatchPattern":"match bar_spec_to_bybit_interval(&bar_spec) {\n    Ok(interval) => request(interval),\n    Err(e) => log::warn!(\"Bybit bar request rejected: {e}; falling back to 1-DAY bars\"),\n}","preventionTips":["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"],"tags":["bybit","bars","unsupported-interval","data"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}