nautechsystems/nautilus_trader · error

Only EXTERNAL aggregation bars are supported

Error message

Only EXTERNAL aggregation bars are supported

What it means

BitMEX's request_bars only serves venue (exchange) aggregated bars; the client rejects bar types whose aggregation source is not AggregationSource::External. Internally aggregated bars must be built from trades on the Nautilus side, not requested from BitMEX.

Source

Thrown at crates/adapters/bitmex/src/http/client.rs:2304

    }

    /// Request bars for the given bar type.
    ///
    /// # Errors
    ///
    /// Returns an error if the HTTP request fails, parsing fails, or the bar specification is
    /// unsupported by BitMEX.
    pub async fn request_bars(
        &self,
        mut bar_type: BarType,
        start: Option<Timestamp>,
        end: Option<Timestamp>,
        limit: Option<u32>,
        partial: bool,
    ) -> anyhow::Result<Vec<Bar>> {
        bar_type = bar_type.standard();

        anyhow::ensure!(
            bar_type.aggregation_source() == AggregationSource::External,
            "Only EXTERNAL aggregation bars are supported"
        );
        anyhow::ensure!(
            bar_type.spec().price_type == PriceType::Last,
            "Only LAST price type bars are supported"
        );

        if let (Some(start), Some(end)) = (start, end) {
            anyhow::ensure!(
                start < end,
                "Invalid time range: start={start:?} end={end:?}"
            );
        }

        let spec = bar_type.spec();
        let bin_size = match (spec.aggregation, spec.step.get()) {
            (BarAggregation::Minute, 1) => "1m",

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the bar type to use external aggregation, e.g. append -EXTERNAL to the bar type string or set AggregationSource::External.
  2. For internal aggregation, subscribe to trades and let Nautilus aggregate bars locally instead of calling request_bars.
  3. Verify the bar_type before the call with bar_type.aggregation_source() == AggregationSource::External.

Example fix

// before
let bar_type = BarType::new(instrument_id, agg, PriceType::Last, AggregationSource::Internal);
// after
let bar_type = BarType::new(instrument_id, agg, PriceType::Last, AggregationSource::External);
Defensive patterns

Strategy: validation

Validate before calling

if bar_type.aggregation_source() != AggregationSource::External {
    return Err(anyhow::anyhow!("use EXTERNAL aggregation for BitMEX bars"));
}
let bars = client.request_bars(bar_type, start, end, limit, partial).await?;

Prevention

When it happens

Trigger: Requesting bars via request_bars with a BarType whose aggregation_source is INTERNAL (client-side aggregation).

Common situations: Configuring a bar_type string without specifying EXTERNAL (defaults to INTERNAL in some flows); wiring a data request built for internal aggregation into the BitMEX historical client.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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