{"record":{"id":"66ad6a41add9ff35","repo":"nautechsystems/nautilus_trader","slug":"only-external-aggregation-bars-are-supported","errorCode":null,"errorMessage":"Only EXTERNAL aggregation bars are supported","messagePattern":"Only EXTERNAL aggregation bars are supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/client.rs","lineNumber":2304,"sourceCode":"    }\n\n    /// Request bars for the given bar type.\n    ///\n    /// # 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\",","sourceCodeStart":2286,"sourceCodeEnd":2322,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/client.rs#L2286-L2322","documentation":"BitMEX's request_bars only serves venue (exchange) aggregated bars; the client rejects bar types whose aggregation source is not AggregationSource::External. Internally aggregated bars must be built from trades on the Nautilus side, not requested from BitMEX.","triggerScenarios":"Requesting bars via request_bars with a BarType whose aggregation_source is INTERNAL (client-side aggregation).","commonSituations":"Configuring a bar_type string without specifying EXTERNAL (defaults to INTERNAL in some flows); wiring a data request built for internal aggregation into the BitMEX historical client.","solutions":["Change the bar type to use external aggregation, e.g. append -EXTERNAL to the bar type string or set AggregationSource::External.","For internal aggregation, subscribe to trades and let Nautilus aggregate bars locally instead of calling request_bars.","Verify the bar_type before the call with bar_type.aggregation_source() == AggregationSource::External."],"exampleFix":"// before\nlet bar_type = BarType::new(instrument_id, agg, PriceType::Last, AggregationSource::Internal);\n// after\nlet bar_type = BarType::new(instrument_id, agg, PriceType::Last, AggregationSource::External);","handlingStrategy":"validation","validationCode":"if bar_type.aggregation_source() != AggregationSource::External {\n    return Err(anyhow::anyhow!(\"use EXTERNAL aggregation for BitMEX bars\"));\n}\nlet bars = client.request_bars(bar_type, start, end, limit, partial).await?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Append -EXTERNAL to bar type strings used with BitMEX.","Route INTERNAL-aggregated bars through local aggregation, never request_bars.","Centralize bar type construction so the aggregation source is set in one place."],"tags":["bars","validation","bitmex","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}