{"record":{"id":"34aa3d49924c6b42","repo":"nautechsystems/nautilus_trader","slug":"bybit-does-not-support-aggregation-bars","errorCode":null,"errorMessage":"Bybit does not support {aggregation:?} bars","messagePattern":"Bybit does not support (.+?) bars","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":328,"sourceCode":"            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.\npub fn parse_spot_instrument(\n    definition: &BybitInstrumentSpot,\n    fee_rate: &BybitFeeRate,\n    ts_event: UnixNanos,\n    ts_init: UnixNanos,","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L310-L346","documentation":"The catch-all branch of bar_spec_to_bybit_interval rejects any BarAggregation the Bybit adapter does not map to a kline interval at all. Only Minute, Hour, Day, Week and Month are supported; aggregations like Tick or Volume cannot be requested from Bybit's REST kline endpoints and raise this anyhow error.","triggerScenarios":"Calling request_bars with a BarSpecification whose aggregation is Tick, Volume, Value, DollarValue or any other non-time aggregation (e.g. 100-TICK bars or 1000-VOLUME bars via the Bybit adapter).","commonSituations":"Subscribing to tick- or volume-aggregated bars assuming the exchange provides them; using a bar spec that works with internal aggregators but not via the direct Bybit historical-request path.","solutions":["Switch the bar spec to a time aggregation (Minute/Hour/Day/Week/Month) that Bybit supports","Use the nautilus internal aggregation engine: subscribe with internal aggregation so ticks/trades are aggregated locally instead of requesting Bybit klines","Aggregate raw trades locally into Tick/Volume bars in your strategy"],"exampleFix":"// before\nlet bar_spec = BarSpecification::new(100, BarAggregation::Tick, PriceType::Last);\n// after (internal aggregation instead of Bybit kline request)\nlet bar_spec = BarSpecification::new(1, BarAggregation::Minute, PriceType::Last);","handlingStrategy":"validation","validationCode":"fn supports_aggregation(a: BarAggregation) -> bool {\n    matches!(a, BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Week | BarAggregation::Month)\n}","typeGuard":"fn is_time_aggregation(a: BarAggregation) -> bool {\n    matches!(a, BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Week | BarAggregation::Month)\n}","tryCatchPattern":"if let Err(e) = request_bars(...).await {\n    log::warn!(\"{e}; switching to internal tick aggregation\");\n    subscribe_with_internal_aggregation(...)?;\n}","preventionTips":["Only request exchange klines for time-based aggregations","Use internal aggregation for Tick/Volume/Value bars","Validate bar specs at config load time, not at request time"],"tags":["bybit","bars","unsupported-aggregation","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"}