{"record":{"id":"48811e06175c8d8f","repo":"nautechsystems/nautilus_trader","slug":"unsupported-bar-aggregation-step-combination-agg","errorCode":null,"errorMessage":"Unsupported bar aggregation/step combination: {aggregation:?}/{step}","messagePattern":"Unsupported bar aggregation/step combination: (.+?)/(.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/data/convert.rs","lineNumber":72,"sourceCode":"        (BarAggregation::Minute, 5) => HistoricalBarSize::Min5,\n        (BarAggregation::Minute, 10) => HistoricalBarSize::Min10,\n        (BarAggregation::Minute, 15) => HistoricalBarSize::Min15,\n        (BarAggregation::Minute, 20) => HistoricalBarSize::Min20,\n        (BarAggregation::Minute, 30) => HistoricalBarSize::Min30,\n        // Hours\n        (BarAggregation::Hour, 1) => HistoricalBarSize::Hour,\n        (BarAggregation::Hour, 2) => HistoricalBarSize::Hour2,\n        (BarAggregation::Hour, 3) => HistoricalBarSize::Hour3,\n        (BarAggregation::Hour, 4) => HistoricalBarSize::Hour4,\n        (BarAggregation::Hour, 8) => HistoricalBarSize::Hour8,\n        // Days\n        (BarAggregation::Day, 1) => HistoricalBarSize::Day,\n        // Weeks\n        (BarAggregation::Week, 1) => HistoricalBarSize::Week,\n        // Months\n        (BarAggregation::Month, 1) => HistoricalBarSize::Month,\n        _ => {\n            anyhow::bail!(\"Unsupported bar aggregation/step combination: {aggregation:?}/{step}\",);\n        }\n    };\n\n    Ok(bar_size)\n}\n\n/// Convert Nautilus PriceType to IB WhatToShow.\n#[must_use]\npub fn price_type_to_ib_what_to_show(price_type: PriceType) -> HistoricalWhatToShow {\n    match price_type {\n        PriceType::Last => HistoricalWhatToShow::Trades,\n        PriceType::Bid => HistoricalWhatToShow::Bid,\n        PriceType::Ask => HistoricalWhatToShow::Ask,\n        PriceType::Mid => HistoricalWhatToShow::MidPoint,\n        _ => HistoricalWhatToShow::Trades, // Default to trades\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/data/convert.rs#L54-L90","documentation":"IB historical bar sizes only support a fixed set of aggregation/step pairs (1s, 5s, ..., 1 Day, 1 Week, 1 Month). bar_type_to_ib_bar_size maps Nautilus BarAggregation/step to IB HistoricalBarSize and fails for any unsupported combination.","triggerScenarios":"Calling request_bars with a BarType aggregated by something other than Second/Minute/Hour/Day/Week/Month with step 1 — e.g. Minute with step 5? (check the map: Minute/1 etc.) or unsupported steps like 2-day or 15-second bars when not in the mapping table.","commonSituations":"Requesting bars with non-unit steps (e.g. 2 Hour) or exotic aggregations (Tick, Value) that IB history does not offer.","solutions":["Use an IB-supported bar size: step 1 with Second/Minute/Hour/Day/Week/Month aggregations matching the adapter's supported set","Aggregate locally: request the smallest supported IB bar size and build the desired bars client-side","Check the mapping table in bar_type_to_ib_bar_size to confirm the exact supported pairs"],"exampleFix":"// before\nlet bar_type = BarType::from(\"AAPL.SMART-2-HOUR-LAST-EXTERNAL\");\n// after\nlet bar_type = BarType::from(\"AAPL.SMART-1-HOUR-LAST-EXTERNAL\"); // aggregate 2h locally if needed","handlingStrategy":"validation","validationCode":"fn ib_bar_supported(aggregation: BarAggregation, step: u32) -> bool {\n    matches!(\n        (aggregation, step),\n        (BarAggregation::Second, 1 | 5 | 10 | 15 | 30)\n            | (BarAggregation::Minute, 1 | 2 | 3 | 5 | 10 | 15 | 20 | 30)\n            | (BarAggregation::Hour, 1 | 2 | 3 | 4 | 8)\n            | (BarAggregation::Day, 1)\n            | (BarAggregation::Week, 1)\n            | (BarAggregation::Month, 1)\n    )\n}","typeGuard":null,"tryCatchPattern":"match bar_type_to_ib_bar_size(&bar_type) {\n    Ok(size) => size,\n    Err(e) if e.to_string().contains(\"Unsupported bar aggregation\") => {\n        tracing::warn!(\"{} not supported by IB; falling back to 1-minute bars\", bar_type);\n        bar_type_to_ib_bar_size(&fallback_bar_type)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check the supported aggregation/step table before building request BarTypes","Request the smallest supported bar size and aggregate locally for custom steps","Avoid Tick/Value aggregations for IB historical requests"],"tags":["rust","bars","historical-data","interactive-brokers"],"backgroundTag":"unsupported-enum-value","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"}