nautechsystems/nautilus_trader · error
historical BinanceBar requests require LAST price type
Error message
historical BinanceBar requests require LAST price type
What it means
Binance klines are computed from last-trade prices only, so the custom `BinanceBar` request path enforces `PriceType::Last` on the parsed bar type. Bar types with MID, BID, or ASK price types are rejected before the HTTP fetch is spawned.
Source
Thrown at crates/adapters/binance/src/futures/data.rs:2636
Ok(())
}
/// Requests Binance futures custom data.
///
/// Spawned fetch failures are logged and no response is emitted, matching
/// the existing request-path behavior for other Binance adapter requests.
fn request_data(&self, request: RequestCustomData) -> anyhow::Result<()> {
let data_type = request.data_type.clone();
let data_type_name = data_type.type_name().to_string();
if data_type_name == "BinanceBar" {
let bar_type = parse_binance_bar_type(&data_type)?;
anyhow::ensure!(
bar_type.aggregation_source() == AggregationSource::External,
"historical BinanceBar requests require EXTERNAL aggregation"
);
anyhow::ensure!(
bar_type.spec().price_type == PriceType::Last,
"historical BinanceBar requests require LAST price type"
);
anyhow::ensure!(
bar_type.spec().is_time_aggregated(),
"historical BinanceBar requests require time aggregation"
);
let http = self.http_client.clone();
let sender = self.data_sender.clone();
let request_id = request.request_id;
let client_id = request.client_id;
let start = request.start;
let end = request.end;
let limit = request.limit.map(|value| value.get() as u32);
let params = request.params;
let clock = self.clock;
let venue = self.venue();
let start_nanos = datetime_to_unix_nanos(start);View on GitHub (pinned to a4b06ed870)
Solutions
- Use a LAST price type bar, e.g. `BTCUSDT-PERP.BINANCE-1-MINUTE-LAST-EXTERNAL`
- If quote-price bars are required, build them locally from book/quote data (INTERNAL aggregation) rather than requesting them from Binance
Example fix
# before
bar_type = BarType.from_str('BTCUSDT-PERP.BINANCE-1-MINUTE-MID-EXTERNAL')
# after
bar_type = BarType.from_str('BTCUSDT-PERP.BINANCE-1-MINUTE-LAST-EXTERNAL') Defensive patterns
Strategy: validation
Validate before calling
from nautilus_trader.model.enums import PriceType
def is_requestable_binance_bar(bar_type) -> bool:
return bar_type.spec.price_type == PriceType.LAST
if not is_requestable_binance_bar(bar_type):
raise ValueError(f'{bar_type} uses {bar_type.spec.price_type}; Binance klines are LAST price only') Type guard
def is_last_price_bar(bar_type) -> bool:
return bar_type.spec.price_type == PriceType.LAST Try / catch
try:
actor.request_custom_data(data_type, ...)
except Exception as e:
if 'require LAST price type' in str(e):
raise ValueError('Binance klines are last-trade candles; request a -LAST- bar type or aggregate quote bars locally') from e
raise Prevention
- Default all Binance bar configs to LAST price — MID/BID/ASK klines do not exist there
- For quote-price candles, run a local aggregator over the book stream instead of requesting history
When it happens
Trigger: `request_data` with data type name `BinanceBar` and a bar type like `BTCUSDT-PERP.BINANCE-1-MINUTE-MID-EXTERNAL` or `-BID-EXTERNAL` / `-ASK-EXTERNAL`.
Common situations: Strategies using MID bars ported from venues that serve quote-price klines; reusing a generic bar config (often MID) across venues; assuming Binance serves bid/ask candles.
Related errors
- Binance historical bars require LAST price type
- historical BinanceBar requests require EXTERNAL aggregation
- historical BinanceBar requests require time aggregation
- Binance historical bars require EXTERNAL aggregation
- historical open interest request requires `period` metadata
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/f623fff7b8170706.
Report an issue: GitHub.