nautechsystems/nautilus_trader · error

Unsupported bar aggregation: {:?}

Error message

Unsupported bar aggregation: {:?}

What it means

The dYdX adapter maps NautilusTrader BarSpecifications onto its fixed set of candle resolutions. Within the step==1 branch, only Minute, Hour, and Day aggregations map to dYdX enums; any other aggregation with step 1 (Week, Second, Tick, Volume, etc.) is rejected.

Source

Thrown at crates/adapters/dydx/src/common/enums.rs:681

    /// 1 day candles.
    #[serde(rename = "1DAY")]
    #[strum(serialize = "1DAY")]
    OneDay,
}

impl DydxCandleResolution {
    /// Maps a Nautilus [`BarSpecification`] to a dYdX candle resolution.
    ///
    /// # Errors
    ///
    /// Returns an error if the step/aggregation combination is not supported.
    pub fn from_bar_spec(spec: &BarSpecification) -> anyhow::Result<Self> {
        match spec.step.get() {
            1 => match spec.aggregation {
                BarAggregation::Minute => Ok(Self::OneMinute),
                BarAggregation::Hour => Ok(Self::OneHour),
                BarAggregation::Day => Ok(Self::OneDay),
                _ => anyhow::bail!("Unsupported bar aggregation: {:?}", spec.aggregation),
            },
            5 if spec.aggregation == BarAggregation::Minute => Ok(Self::FiveMinutes),
            15 if spec.aggregation == BarAggregation::Minute => Ok(Self::FifteenMinutes),
            30 if spec.aggregation == BarAggregation::Minute => Ok(Self::ThirtyMinutes),
            4 if spec.aggregation == BarAggregation::Hour => Ok(Self::FourHours),
            step => anyhow::bail!(
                "Unsupported bar step: {step} with aggregation {:?}",
                spec.aggregation
            ),
        }
    }
}

/// dYdX network environment (mainnet vs testnet).
///
/// This selects the underlying Cosmos chain for transaction submission.
#[derive(
    Copy,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use Minute, Hour, or Day aggregation with step 1 for dYdX
  2. Aggregate weekly bars locally from daily data instead of requesting them from dYdX
  3. Switch to an adapter that supports the requested aggregation

Example fix

// before
let spec = BarSpecification::new(1.into(), BarAggregation::Week, PriceType::Last);
// after
let spec = BarSpecification::new(1.into(), BarAggregation::Day, PriceType::Last);
Defensive patterns

Strategy: validation

Validate before calling

fn is_dydx_bar_spec_supported(spec: &BarSpecification) -> bool {
    match spec.step.get() {
        1 => matches!(spec.aggregation, BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day),
        5 | 15 | 30 => spec.aggregation == BarAggregation::Minute,
        4 => spec.aggregation == BarAggregation::Hour,
        _ => false,
    }
}

Prevention

When it happens

Trigger: Calling from_bar_spec (via bar data subscription/request) with a BarSpecification of step 1 and an aggregation outside Minute/Hour/Day, e.g. 1 WEEK bars or 1 SECOND bars.

Common situations: Configuring 1-week candles against dYdX; reusing bar specs designed for Derive (which supports 1 WEEK) with the dYdX adapter.

Related errors


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