nautechsystems/nautilus_trader · error
Only LAST price type bars are supported
Error message
Only LAST price type bars are supported
What it means
BitMEX trade bins are published on last-traded price, so request_bars rejects bar specs whose PriceType is not PriceType::Last. Other price types (Bid, Ask, Mid, Index) have no venue-side equivalent on BitMEX.
Source
Thrown at crates/adapters/bitmex/src/http/client.rs:2308
/// # 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",
(BarAggregation::Minute, 5) => "5m",
(BarAggregation::Hour, 1) => "1h",
(BarAggregation::Day, 1) => "1d",
_ => anyhow::bail!(View on GitHub (pinned to 18893faf8b)
Solutions
- Switch the bar spec's price type to LAST.
- If you need bid/ask or mid bars, subscribe to quotes and aggregate internally (INTERNAL source) instead of using request_bars.
- Validate price_type == PriceType::Last on the BarSpec before issuing the request.
Example fix
// before let spec = BarSpecification::new(BarAggregation::Minute, PriceType::Bid, 1); // after let spec = BarSpecification::new(BarAggregation::Minute, PriceType::Last, 1);
Defensive patterns
Strategy: validation
Validate before calling
if bar_type.spec().price_type != PriceType::Last {
return Err(anyhow::anyhow!("BitMEX bars require PriceType::Last"));
}
let bars = client.request_bars(bar_type, start, end, limit, partial).await?; Prevention
- Default BitMEX bar specs to PriceType::Last.
- Validate the full bar spec (aggregation, step, price type) before any venue request.
- Document BitMEX-supported specs in your config schema.
When it happens
Trigger: Calling request_bars with a bar spec whose price type is Bid, Ask, Mid, or Index.
Common situations: Constructing bar type strings like "XBTUSD*BITMEX/bid-1-minute*..."; porting config from another adapter (e.g. a CLOB with bid/ask bars) without adjusting for BitMEX limits.
Related errors
- historical BinanceBar requests require LAST price type
- Only EXTERNAL aggregation bars are supported
- Derive candles are trade-based; only PriceType::Last is supp
- 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/dd86fa0fb0aef08c.
Report an issue: GitHub.