nautechsystems/nautilus_trader · error

Derive only supports EXTERNAL aggregation source (got {bar_t

Error message

Derive only supports EXTERNAL aggregation source (got {bar_type})

What it means

`request_bars` for the Derive adapter only supports bars aggregated externally (i.e. the adapter fetches provider candles, not Nautilus-built ones). It throws via `anyhow::ensure!` when the `BarType`'s aggregation source is not `AggregationSource::External`.

Source

Thrown at crates/adapters/derive/src/data.rs:1317

                updates,
                start_nanos,
                end_nanos,
                clock.get_time_ns(),
                params,
            ));

            if let Err(e) = sender.send(DataEvent::Response(response)) {
                log::error!("Failed to send Derive funding rates response: {e}");
            }
            Ok(())
        });

        Ok(())
    }

    fn request_bars(&self, request: RequestBars) -> anyhow::Result<()> {
        let bar_type = request.bar_type;
        anyhow::ensure!(
            bar_type.aggregation_source() == AggregationSource::External,
            "Derive only supports EXTERNAL aggregation source (got {bar_type})",
        );
        let spec = bar_type.spec();
        anyhow::ensure!(
            spec.price_type == PriceType::Last,
            "Derive candles are trade-based; only PriceType::Last is supported (got {bar_type})",
        );

        let instrument_id = bar_type.instrument_id();
        let instrument = self
            .instruments
            .get_cloned(&instrument_id)
            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;
        let venue_symbol = format_venue_symbol(&instrument_id)?.to_string();
        let price_precision = instrument.price_precision();
        let size_precision = instrument.size_precision();

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Construct the BarType with `AggregationSource::External`, e.g. `BarType::new(instrument_id, spec, AggregationSource::External)`.
  2. Update strategy/config bar definitions to specify EXTERNAL aggregation for Derive.
  3. If internal aggregation is required, feed Derive trade data and aggregate locally instead of using request_bars.
  4. Log the bar_type in the error message to spot which definition is wrong.

Example fix

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

Strategy: validation

Validate before calling

// Rust
if bar_type.aggregation_source() != AggregationSource::External {
    return Err(anyhow!("Derive requires EXTERNAL aggregation: {bar_type}"));
}

Try / catch

if let Err(e) = client.request_bars(req) {
    if e.to_string().contains("EXTERNAL aggregation") {
        // rebuild request with AggregationSource::External
    }
}

Prevention

When it happens

Trigger: Calling `request_bars` with a `BarType` created with `AggregationSource::Internal` (e.g. `BarType::new(id, spec, AggregationSource::Internal)`), which would require Nautilus-side tick aggregation that Derive does not serve.

Common situations: Bar specs copied from adapters that support internal aggregation; strategy configs defining internal bars; docs/examples from other venues pasted into a Derive config.

Related errors


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