{"record":{"id":"dd86fa0fb0aef08c","repo":"nautechsystems/nautilus_trader","slug":"only-last-price-type-bars-are-supported","errorCode":null,"errorMessage":"Only LAST price type bars are supported","messagePattern":"Only LAST price type bars are supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/client.rs","lineNumber":2308,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if the HTTP request fails, parsing fails, or the bar specification is\n    /// unsupported by BitMEX.\n    pub async fn request_bars(\n        &self,\n        mut bar_type: BarType,\n        start: Option<Timestamp>,\n        end: Option<Timestamp>,\n        limit: Option<u32>,\n        partial: bool,\n    ) -> anyhow::Result<Vec<Bar>> {\n        bar_type = bar_type.standard();\n\n        anyhow::ensure!(\n            bar_type.aggregation_source() == AggregationSource::External,\n            \"Only EXTERNAL aggregation bars are supported\"\n        );\n        anyhow::ensure!(\n            bar_type.spec().price_type == PriceType::Last,\n            \"Only LAST price type bars are supported\"\n        );\n\n        if let (Some(start), Some(end)) = (start, end) {\n            anyhow::ensure!(\n                start < end,\n                \"Invalid time range: start={start:?} end={end:?}\"\n            );\n        }\n\n        let spec = bar_type.spec();\n        let bin_size = match (spec.aggregation, spec.step.get()) {\n            (BarAggregation::Minute, 1) => \"1m\",\n            (BarAggregation::Minute, 5) => \"5m\",\n            (BarAggregation::Hour, 1) => \"1h\",\n            (BarAggregation::Day, 1) => \"1d\",\n            _ => anyhow::bail!(","sourceCodeStart":2290,"sourceCodeEnd":2326,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/client.rs#L2290-L2326","documentation":"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.","triggerScenarios":"Calling request_bars with a bar spec whose price type is Bid, Ask, Mid, or Index.","commonSituations":"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.","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."],"exampleFix":"// before\nlet spec = BarSpecification::new(BarAggregation::Minute, PriceType::Bid, 1);\n// after\nlet spec = BarSpecification::new(BarAggregation::Minute, PriceType::Last, 1);","handlingStrategy":"validation","validationCode":"if bar_type.spec().price_type != PriceType::Last {\n    return Err(anyhow::anyhow!(\"BitMEX bars require PriceType::Last\"));\n}\nlet bars = client.request_bars(bar_type, start, end, limit, partial).await?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["bars","validation","bitmex","price-type"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}