{"record":{"id":"6c72f36f9c267eba","repo":"nautechsystems/nautilus_trader","slug":"aggregation-type-not-supported-for-time-bars","errorCode":null,"errorMessage":"Aggregation type {} not supported for time bars","messagePattern":"Aggregation type (.+?) not supported for time bars","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/data/bar.rs","lineNumber":322,"sourceCode":"                year = year\n                    .checked_sub(step_i32)\n                    .expect(\"year arithmetic underflow\");\n            }\n\n            loop {\n                let next_year = year\n                    .checked_add(step_i32)\n                    .expect(\"year arithmetic overflow\");\n\n                if year_start(next_year) > now {\n                    break;\n                }\n                year = next_year;\n            }\n\n            year_start(year)\n        }\n        _ => panic!(\n            \"Aggregation type {} not supported for time bars\",\n            spec.aggregation\n        ),\n    }\n}\n\n/// Finds the closest smaller time based on a daily time origin and period.\n///\n/// This function calculates the most recent time that is aligned with the given period\n/// and is less than or equal to the current time.\nfn find_closest_smaller_time(\n    now: Timestamp,\n    daily_time_origin: SignedDuration,\n    period: SignedDuration,\n) -> Timestamp {\n    // Floor to start of day\n    let day_start = Offset::UTC\n        .to_timestamp(Offset::UTC.to_datetime(now).date().at(0, 0, 0, 0))","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/data/bar.rs#L304-L340","documentation":"`get_time_bar_start` computes the aligned start timestamp for time-based bars. Its match handles the eight time aggregations; the `_ => panic!(\"Aggregation type {} not supported for time bars\", spec.aggregation)` arm fires when the bar's aggregation is inherently non-time based, so no calendar-aligned start exists. This is called from timer setup (`start_timer_internal`) when registering time-bar aggregators.","triggerScenarios":"Registering or starting a bar aggregator whose BarSpecification uses a non-time aggregation (Tick, Value) but a time-based start computation; misconfigured BarType strings like `EUR/USD.LAST-TICK` routed through the time-bar start path.","commonSituations":"Strategy configs mixing tick bars and time bars where the timer registration path doesn't dispatch on aggregation kind; custom adapter code calling `get_time_bar_start` for a bar type parsed from user config.","solutions":["Verify the BarType/aggregation is time based (use `aggregation.is_time_based()`-style check or match on the enum) before computing a time bar start.","Route tick/value bar types to their non-timer aggregation path instead of `start_timer_internal`.","Fix the BarType string in config so the aggregation is a time-based variant."],"exampleFix":"// before\nlet start = get_time_bar_start(now, &bar_type, origin); // panics for VALUE bars\n\n// after\nif !matches!(bar_type.spec().aggregation,\n    BarAggregation::Millisecond | BarAggregation::Second | BarAggregation::Minute\n    | BarAggregation::Hour | BarAggregation::Day | BarAggregation::Week\n    | BarAggregation::Month | BarAggregation::Year) {\n    anyhow::bail!(\"cannot compute time bar start for non-time aggregation\");\n}\nlet start = get_time_bar_start(now, &bar_type, origin);","handlingStrategy":"validation","validationCode":"# Python\nTIME_AGGS = {BarAggregation.MILLISECOND, BarAggregation.SECOND, BarAggregation.MINUTE,\n             BarAggregation.HOUR, BarAggregation.DAY, BarAggregation.WEEK,\n             BarAggregation.MONTH, BarAggregation.YEAR}\nassert bar_type.spec().aggregation in TIME_AGGS, \"time bar start requires a time-based aggregation\"","typeGuard":"def is_time_based(a) -> bool:\n    from nautilus_trader.model.enums import BarAggregation\n    return a in {BarAggregation.MILLISECOND, BarAggregation.SECOND, BarAggregation.MINUTE,\n                 BarAggregation.HOUR, BarAggregation.DAY, BarAggregation.WEEK,\n                 BarAggregation.MONTH, BarAggregation.YEAR}","tryCatchPattern":null,"preventionTips":["Dispatch on aggregation kind before registering time-bar timers","Validate bar type specs in strategy config before the engine starts","Never route tick/value bar types through get_time_bar_start"],"tags":["rust","bars","aggregation","panic"],"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"}