nautechsystems/nautilus_trader · error

Unsupported bar aggregation type: {}

Error message

Unsupported bar aggregation type: {}

What it means

bar_spec_to_tardis_trade_bar_string maps a NautilusTrader BarAggregation back to Tardis's trade bar naming (e.g. 'trade_bar_1m'). Only Millisecond, Second, Minute, Tick, and Volume aggregations are supported; any other aggregation (e.g. Day, Price) bails with this message.

Source

Thrown at crates/adapters/tardis/src/common/parse.rs:405

        }
        BarAggregation::Day => {
            let minutes = bar_spec
                .step
                .get()
                .checked_mul(1440)
                .context("bar specification step overflow")?;
            return Ok(format!("trade_bar_{minutes}m"));
        }
        _ => {}
    }

    let suffix = match bar_spec.aggregation {
        BarAggregation::Millisecond => "ms",
        BarAggregation::Second => "s",
        BarAggregation::Minute => "m",
        BarAggregation::Tick => "ticks",
        BarAggregation::Volume => "vol",
        _ => anyhow::bail!("Unsupported bar aggregation type: {}", bar_spec.aggregation),
    };
    Ok(format!("trade_bar_{}{}", bar_spec.step, suffix))
}

#[cfg(test)]
mod tests {
    use std::str::FromStr;

    use rstest::rstest;

    use super::*;

    #[rstest]
    #[case(TardisExchange::Binance, "ETHUSDT", "ETHUSDT.BINANCE")]
    #[case(TardisExchange::Bitmex, "XBTUSD", "XBTUSD.BITMEX")]
    #[case(TardisExchange::Bybit, "BTCUSDT", "BTCUSDT.BYBIT")]
    #[case(TardisExchange::OkexFutures, "BTC-USD-200313", "BTC-USD-200313.OKEX")]
    #[case(TardisExchange::HuobiDmLinearSwap, "FOO-BAR", "FOO-BAR.HUOBI")]

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use one of the supported aggregations: Millisecond, Second, Minute, Tick, or Volume
  2. Convert unsupported aggregations (e.g. 1 day) to an equivalent supported unit (1440 minutes) before calling
  3. Do not use the Tardis trade-bar request path for Price/Value aggregated bars; fetch raw trades and aggregate locally
  4. Check the BarSpec construction in your config and correct the aggregation field

Example fix

// before
let spec = BarSpec::new(..., BarAggregation::Day, ...);
let s = bar_spec_to_tardis_trade_bar_string(&spec)?; // bails
// after
let spec = BarSpec::new(..., BarAggregation::Minute, ...); // step 1440
let s = bar_spec_to_tardis_trade_bar_string(&spec)?; // "trade_bar_1440m"
Defensive patterns

Strategy: validation

Validate before calling

let supported = matches!(
    bar_spec.aggregation,
    BarAggregation::Millisecond
        | BarAggregation::Second
        | BarAggregation::Minute
        | BarAggregation::Tick
        | BarAggregation::Volume
);
if !supported { /* convert to a supported unit or skip */ }

Prevention

When it happens

Trigger: Calling bar_spec_to_tardis_trade_bar_string (exposed via py_bar_spec_to_tardis_trade_bar_string) with a BarSpec whose aggregation is not one of Millisecond/Second/Minute/Tick/Volume — e.g. Day, Hour, or Price aggregation.

Common situations: Building Tardis requests from user-configured bar specs in Python where DAY/HOUR aggregations were selected; aggregations added to the enum after this mapping was written; requesting value/price bars from Tardis trade bars.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/2e1004b0899540a3. Report an issue: GitHub.