{"record":{"id":"f623fff7b8170706","repo":"nautechsystems/nautilus_trader","slug":"historical-binancebar-requests-require-last-price","errorCode":null,"errorMessage":"historical BinanceBar requests require LAST price type","messagePattern":"historical BinanceBar requests require LAST price type","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":2682,"sourceCode":"\n        Ok(())\n    }\n\n    /// Requests Binance futures custom data.\n    ///\n    /// Spawned fetch failures are logged and no response is emitted, matching\n    /// the existing request-path behavior for other Binance adapter requests.\n    fn request_data(&self, request: RequestCustomData) -> anyhow::Result<()> {\n        let data_type = request.data_type.clone();\n        let data_type_name = data_type.type_name().to_string();\n\n        if data_type_name == \"BinanceBar\" {\n            let bar_type = parse_binance_bar_type(&data_type)?;\n            anyhow::ensure!(\n                bar_type.aggregation_source() == AggregationSource::External,\n                \"historical BinanceBar requests require EXTERNAL aggregation\"\n            );\n            anyhow::ensure!(\n                bar_type.spec().price_type == PriceType::Last,\n                \"historical BinanceBar requests require LAST price type\"\n            );\n            anyhow::ensure!(\n                bar_type.spec().is_time_aggregated(),\n                \"historical BinanceBar requests require time aggregation\"\n            );\n            let http = self.http_client.clone();\n            let sender = self.data_sender.clone();\n            let request_id = request.request_id;\n            let client_id = request.client_id;\n            let start = request.start;\n            let end = request.end;\n            let limit = request.limit.map(|value| value.get() as u32);\n            let params = request.params;\n            let clock = self.clock;\n            let venue = self.venue();\n            let start_nanos = datetime_to_unix_nanos(start);","sourceCodeStart":2664,"sourceCodeEnd":2700,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L2664-L2700","documentation":"Historical BinanceBar requests must use the LAST (trade) price type, since Binance klines are built from trades. Other price types (MID, BID, ASK) have no Binance REST kline equivalent, so the request is rejected after the aggregation-source check.","triggerScenarios":"Sending RequestCustomData for \"BinanceBar\" where bar_type.spec().price_type is not PriceType::Last (e.g. Bid or Ask bars).","commonSituations":"Strategies using bid/ask bars live attempting the same bar type for backfill; generic historical-request code that forwards the strategy's configured price type; copying spot configs where quote-side bars exist.","solutions":["Set the bar spec price type to PriceType::Last for historical BinanceBar requests","Use a different data request (e.g. quotes/ticks) if bid/ask-based history is needed","Separate live bar configs (any price type, internal) from historical request configs (LAST, external)"],"exampleFix":"// before\nBarSpecification::new(1, BarAggregation::Minute, PriceType::Bid)\n// after\nBarSpecification::new(1, BarAggregation::Minute, PriceType::Last)","handlingStrategy":"validation","validationCode":"fn can_request_binance_bar_history(bar_type: &BarType) -> bool {\n    bar_type.spec().price_type == PriceType::Last\n}","typeGuard":"fn is_last_price_bar(bt: &BarType) -> bool {\n    bt.spec().price_type == PriceType::Last\n}","tryCatchPattern":"match client.request_data(request) {\n    Err(e) if e.to_string().contains(\"LAST price type\") => {\n        let last_bar = rebuild_bar_type(request.bar_type, PriceType::Last);\n        client.request_data(request.with_bar_type(last_bar))?;\n    }\n    r => r?,\n}","preventionTips":["Use PriceType::Last for all Binance historical bar requests","Treat bid/ask bars as internal-aggregation-only on Binance","Validate bar specs (Last + External + time aggregation) before sending history requests"],"tags":["validation","bars","historical-data","price-type"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}