nautechsystems/nautilus_trader · error
Derive candles are trade-based; only PriceType::Last is supp
Error message
Derive candles are trade-based; only PriceType::Last is supported (got {bar_type}) What it means
Derive's candle endpoints are trade-based, so `request_bars` only accepts bars whose price type is `PriceType::Last`. Via `anyhow::ensure!` it rejects bar specs using bid/ask/mid/other price types, which Derive cannot source.
Source
Thrown at crates/adapters/derive/src/data.rs:1322
));
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();
let period = bar_spec_to_derive_period(spec.aggregation, spec.step.get() as u64)
.with_context(|| format!("unsupported Derive bar spec for {bar_type}"))?;
let http_client = self.http_client.clone();
let sender = self.data_sender.clone();View on GitHub (pinned to 18893faf8b)
Solutions
- Change the bar specification's price type to `PriceType::Last`, e.g. `BarSpecification::new(1, BarAggregation::Minute, PriceType::Last)`.
- Audit strategy config bar definitions and replace bid/ask/mid specs with last-trade specs.
- If quote-based bars are needed, collect Derive quotes and aggregate internally rather than via request_bars.
- Check the bar_type echoed in the error message to identify the offending spec quickly.
Example fix
// before let spec = BarSpecification::new(1, BarAggregation::Minute, PriceType::Mid); // after let spec = BarSpecification::new(1, BarAggregation::Minute, PriceType::Last);
Defensive patterns
Strategy: validation
Validate before calling
// Rust
if bar_type.spec().price_type != PriceType::Last {
return Err(anyhow!("Derive bars require PriceType::Last: {bar_type}"));
} Try / catch
if let Err(e) = client.request_bars(req) {
if e.to_string().contains("PriceType::Last") {
// rebuild spec with PriceType::Last
}
} Prevention
- Always use PriceType::Last in Derive bar specifications.
- Audit configs copied from bid/ask-driven venues.
- Add a validation step that checks price type before requests.
- Document adapter bar constraints next to strategy config schema.
When it happens
Trigger: Calling `request_bars` with a BarType whose `BarSpecification` price type is `Bid`, `Ask`, or `Mid` (e.g. 1-minute bid bars), which would need quote-based aggregation Derive does not provide.
Common situations: Strategy configs built for FX/quotes-driven venues requesting bid/ask bars; generic bar setup helpers defaulting to Mid; copying bar specs between adapters without adjusting price type.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- historical BinanceBar requests require LAST price type
- Only LAST price type bars are supported
- Derive only supports EXTERNAL aggregation source (got {bar_t
- Lighter candles only support LAST price type
- Unsupported bar specification for AX: {step}-{:?}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/df8b96e7cb742de6.
Report an issue: GitHub.