nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported bar specification for AX: {step}-{:?}

Error message

Unsupported bar specification for AX: {step}-{:?}

What it means

TryFrom<&BarSpecification> for AxCandleWidth maps NautilusTrader bar specs onto ArchitectX's fixed candle-width enum. Architect only supports 1s, 5s, 1m, 5m, 15m, 1h and 1d; any other step/aggregation combination (including tick- or volume-based aggregation) is unsupported and rejected with the step and aggregation in the message.

Source

Thrown at crates/adapters/architect_ax/src/common/enums.rs:636

    #[serde(rename = "1d")]
    #[strum(serialize = "1d")]
    Days1,
}

impl TryFrom<&BarSpecification> for AxCandleWidth {
    type Error = anyhow::Error;

    fn try_from(spec: &BarSpecification) -> Result<Self, Self::Error> {
        let step = spec.step.get();
        match (step, spec.aggregation) {
            (1, BarAggregation::Second) => Ok(Self::Seconds1),
            (5, BarAggregation::Second) => Ok(Self::Seconds5),
            (1, BarAggregation::Minute) => Ok(Self::Minutes1),
            (5, BarAggregation::Minute) => Ok(Self::Minutes5),
            (15, BarAggregation::Minute) => Ok(Self::Minutes15),
            (1, BarAggregation::Hour) => Ok(Self::Hours1),
            (1, BarAggregation::Day) => Ok(Self::Days1),
            _ => anyhow::bail!(
                "Unsupported bar specification for AX: {step}-{:?}",
                spec.aggregation,
            ),
        }
    }
}

/// WebSocket market data request type (client to server).
///
/// # References
/// - <https://docs.architect.exchange/api-reference/marketdata/md-ws>
#[derive(
    Clone,
    Copy,
    Debug,
    Display,
    Eq,
    PartialEq,

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Use one of the supported widths: 1-SECOND, 5-SECOND, 1-MINUTE, 5-MINUTE, 15-MINUTE, 1-HOUR, 1-DAY
  2. Aggregate unsupported widths client-side from a finer supported width (e.g. build 30s bars from 5s bars)
  3. Check spec.step/spec.aggregation against the accepted set before building the AX request

Example fix

// before
let spec = BarSpecification::new(30, BarAggregation::Second, PriceType::Last);
let width = AxCandleWidth::try_from(&spec)?; // Unsupported bar specification for AX: 30-Second

// after
let spec = BarSpecification::new(5, BarAggregation::Second, PriceType::Last);
let width = AxCandleWidth::try_from(&spec)?; // Seconds5
Defensive patterns

Strategy: validation

Validate before calling

// Rust: check before converting
const SUPPORTED: &[(u64, BarAggregation)] = &[
    (1, BarAggregation::Second),
    (5, BarAggregation::Second),
    (1, BarAggregation::Minute),
    (5, BarAggregation::Minute),
    (15, BarAggregation::Minute),
    (1, BarAggregation::Hour),
    (1, BarAggregation::Day),
];
if !SUPPORTED.contains(&(spec.step.get(), spec.aggregation)) {
    anyhow::bail!("unsupported AX bar width: {}", spec);
}
let width = AxCandleWidth::try_from(&spec)?;

Type guard

fn is_supported_ax_width(spec: &BarSpecification) -> bool {
    matches!(
        (spec.step.get(), spec.aggregation),
        (1, BarAggregation::Second)
            | (5, BarAggregation::Second)
            | (1, BarAggregation::Minute)
            | (5, BarAggregation::Minute)
            | (15, BarAggregation::Minute)
            | (1, BarAggregation::Hour)
            | (1, BarAggregation::Day)
    )
}

Try / catch

let width = match AxCandleWidth::try_from(&spec) {
    Ok(w) => w,
    Err(e) => {
        tracing::warn!("{e}; falling back to 1-minute bars");
        AxCandleWidth::Minutes1
    }
};

Prevention

When it happens

Trigger: Requesting AX market data or historical bars with e.g. BarSpecification(30, BarAggregation::Second), 4-hour bars, daily step 7, or any BarAggregation::Tick/Volume spec — any pair not in the eight accepted matches.

Common situations: Reusing a strategy's bar config (tuned for another venue) with the architect_ax adapter; assuming arbitrary step values are negotiated like on crypto venues; subscribing with the default bar spec from an example.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/0c3797ec6802bc46. Report an issue: GitHub.