{"record":{"id":"b8933cb948341463","repo":"nautechsystems/nautilus_trader","slug":"bybit-only-supports-1-month-interval-bars","errorCode":null,"errorMessage":"Bybit only supports 1 MONTH interval bars","messagePattern":"Bybit only supports 1 MONTH interval bars","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":323,"sourceCode":"            _ => 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}\n\n/// Parses a spot instrument definition returned by Bybit into a Nautilus currency pair.\n///\n/// # Panics\n///\n/// Panics if the constructed instrument fails validation.","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L305-L341","documentation":"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.","triggerScenarios":"Calling request_bars with a BarSpecification of aggregation Month and step != 1, e.g. 3-MONTH or 6-MONTH bars.","commonSituations":"Requesting quarterly bars from Bybit history, or reusing a bar spec written for venues that support arbitrary monthly steps.","solutions":["Set the bar spec step to 1 (1-MONTH bars)","Request 1-MONTH bars and combine them into quarterly buckets in your strategy","Request 1-DAY bars and aggregate locally to the desired monthly multiple"],"exampleFix":"// before\nlet bar_spec = BarSpecification::new(3, BarAggregation::Month, PriceType::Last);\n// after\nlet bar_spec = BarSpecification::new(1, BarAggregation::Month, PriceType::Last);","handlingStrategy":"validation","validationCode":"assert!(bar_spec.aggregation != BarAggregation::Month || bar_spec.step == 1, \"Bybit only supports 1-MONTH bars\");","typeGuard":null,"tryCatchPattern":"match bar_spec_to_bybit_interval(&bar_spec) {\n    Ok(interval) => request(interval),\n    Err(e) => { log::warn!(\"{e}; requesting 1-MONTH instead\"); request(BybitKlineInterval::Month1) }\n}","preventionTips":["Keep monthly bar specs at step 1 for Bybit","Aggregate 3-/6-month buckets locally from 1-MONTH klines","Reuse bar specs per-venue rather than sharing a global config"],"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-14T00:17:10.932Z"}