{"record":{"id":"bf798cb2276e08c7","repo":"nautechsystems/nautilus_trader","slug":"unsupported-bar-aggregation-for-binance-agg","errorCode":null,"errorMessage":"Unsupported bar aggregation for Binance: {agg:?}","messagePattern":"Unsupported bar aggregation for Binance: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/parse.rs","lineNumber":1469,"sourceCode":"            6 => BinanceKlineInterval::Hour6,\n            8 => BinanceKlineInterval::Hour8,\n            12 => BinanceKlineInterval::Hour12,\n            _ => anyhow::bail!(\"Unsupported hour interval: {step}h\"),\n        },\n        BarAggregation::Day => match step {\n            1 => BinanceKlineInterval::Day1,\n            3 => BinanceKlineInterval::Day3,\n            _ => anyhow::bail!(\"Unsupported day interval: {step}d\"),\n        },\n        BarAggregation::Week => match step {\n            1 => BinanceKlineInterval::Week1,\n            _ => anyhow::bail!(\"Unsupported week interval: {step}w\"),\n        },\n        BarAggregation::Month => match step {\n            1 => BinanceKlineInterval::Month1,\n            _ => anyhow::bail!(\"Unsupported month interval: {step}M\"),\n        },\n        agg => anyhow::bail!(\"Unsupported bar aggregation for Binance: {agg:?}\"),\n    };\n\n    Ok(interval)\n}\n\npub(crate) fn quote_to_l1_deltas(quote: QuoteTick, sequence: u64) -> OrderBookDeltas {\n    let bid_action = if quote.bid_size.is_zero() {\n        BookAction::Delete\n    } else {\n        BookAction::Update\n    };\n    let ask_action = if quote.ask_size.is_zero() {\n        BookAction::Delete\n    } else {\n        BookAction::Update\n    };\n    let bid = OrderBookDelta::new(\n        quote.instrument_id,","sourceCodeStart":1451,"sourceCodeEnd":1487,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/parse.rs#L1451-L1487","documentation":"Thrown by bar_spec_to_binance_interval when the BarSpecification's aggregation method is not one Binance klines can represent. Binance only serves time-based klines (Second, Minute, Hour, Day, Week, Month with fixed steps), so non-time aggregations such as TICK, VOLUME, DOLLAR, VALUE, or sub-second units cannot be mapped and the conversion fails fast.","triggerScenarios":"Subscribing to or requesting bars with a BarType like 'BTCUSDT.BINANCE-100-TICK-LAST-INTERNAL', '-5000-DOLLAR-', '-100-VOLUME-', or '-1-MILLISECOND-' through the Binance data client; the same path is hit by request_bars for historical data.","commonSituations":"Strategies written against the backtest engine or venues that synthesize tick/dollar/volume bars, then pointed at the live Binance adapter; copying a BarType string from a different adapter's docs; sub-second bars expected because Nautilus supports them in backtests.","solutions":["Switch to a time-based aggregation Binance supports, e.g. '1-SECOND-LAST-INTERNAL' or '1-MINUTE-LAST-INTERNAL'.","For TICK/VOLUME/DOLLAR bars, subscribe to the exchange's trade/quote/ticker streams and build the bars yourself (custom data engine or an Actor that aggregates).","Validate every BarType against the supported set in bar_spec_to_binance_interval before starting the node."],"exampleFix":"# before\nbar_type = BarType.from_str('BTCUSDT.BINANCE-100-TICK-LAST-INTERNAL')\n\n# after (aggregate locally from trades if you need tick bars)\nbar_type = BarType.from_str('BTCUSDT.BINANCE-1-SECOND-LAST-INTERNAL')\nclient.subscribe_bars(BarSubscription(bar_type))","handlingStrategy":"validation","validationCode":"TIME_BASED = ('SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH')\n\ndef is_time_based(bar_spec) -> bool:\n    return bar_spec.aggregation_string in TIME_BASED\n\nassert is_time_based(bar_type.spec), 'Binance klines require time-based aggregation'","typeGuard":"def supports_binance_klines(bar_type) -> bool:\n    return bar_type.spec.aggregation_string in (\n        'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH'\n    )","tryCatchPattern":null,"preventionTips":["Never route TICK/VOLUME/DOLLAR/VALUE or sub-second BarTypes to Binance clients.","Build non-time bars locally from trade ticks via a custom Actor.","Log the BarType string in strategy config at startup to catch copy-paste mistakes."],"tags":["binance","bars","aggregation","tick-bars","validation"],"backgroundTag":"unsupported-timeframe","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}