{"record":{"id":"e5712e8b5c86f227","repo":"nautechsystems/nautilus_trader","slug":"only-external-aggregation-is-supported-e5712e","errorCode":null,"errorMessage":"Only EXTERNAL aggregation is supported","messagePattern":"Only EXTERNAL aggregation is supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":2969,"sourceCode":"            trade.ts_init = trade.ts_event;\n        }\n        Ok(parsed)\n    }\n\n    /// Requests bar (kline/candlestick) data.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the bar type is not supported, instrument is not cached,\n    /// or the request fails.\n    pub async fn request_binance_bars(\n        &self,\n        bar_type: BarType,\n        start: Option<Timestamp>,\n        end: Option<Timestamp>,\n        limit: Option<u32>,\n    ) -> anyhow::Result<Vec<crate::common::bar::BinanceBar>> {\n        anyhow::ensure!(\n            bar_type.aggregation_source() == AggregationSource::External,\n            \"Only EXTERNAL aggregation is supported\"\n        );\n\n        let spec = bar_type.spec();\n        let step = spec.step.get();\n        let interval = match spec.aggregation {\n            BarAggregation::Second if step == 1 => \"1s\".to_string(),\n            BarAggregation::Second => {\n                anyhow::bail!(\"Binance Spot supports only the 1s kline interval\")\n            }\n            BarAggregation::Minute => format!(\"{step}m\"),\n            BarAggregation::Hour => format!(\"{step}h\"),\n            BarAggregation::Day => format!(\"{step}d\"),\n            BarAggregation::Week => format!(\"{step}w\"),\n            BarAggregation::Month => format!(\"{step}M\"),\n            a => anyhow::bail!(\"Binance does not support {a:?} aggregation\"),\n        };","sourceCodeStart":2951,"sourceCodeEnd":2987,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L2951-L2987","documentation":"The spot HTTP client only supports requesting bars whose aggregation comes from the venue (AggregationSource::External). Bars with Internal aggregation are generated by Nautilus from lower-level data and cannot be fetched from Binance, so the request is rejected up front.","triggerScenarios":"Requesting historical bars via request_bars with a BarType built with AggregationSource.Internal — e.g. BarType::from_str(\"BTCUSDT-BINANCE-1-MINUTE-LAST-INTERNAL\") — or a strategy configured with internal bar aggregation while asking the client to fetch history.","commonSituations":"Copy-pasting BarType strings from internal-aggregation examples into a historical request; confusion between subscribed (internally synthesized) bars and externally fetched venue bars.","solutions":["Use an External aggregation source in the BarType for historical bar requests","For internally aggregated bars, request the underlying trades/quotes and aggregate locally","Fix the BarType string suffix from -INTERNAL to -EXTERNAL","Document in your actor which bar types are venue-provided"],"exampleFix":"// before\nlet bar_type = BarType::from_str(\"BTCUSDT-BINANCE-1-MINUTE-LAST-INTERNAL\").unwrap();\n// after\nlet bar_type = BarType::from_str(\"BTCUSDT-BINANCE-1-MINUTE-LAST-EXTERNAL\").unwrap();","handlingStrategy":"validation","validationCode":"if bar_type.aggregation_source() != AggregationSource::External {\n    return Err(\"historical bar requests require AggregationSource::External\");\n}","typeGuard":"fn is_externally_aggregated(bt: &BarType) -> bool { bt.aggregation_source() == AggregationSource::External }","tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"Only EXTERNAL aggregation\") => switch_to_external_bar_type_and_retry(), Err(e) => return Err(e), Ok(bars) => Ok(bars) }","preventionTips":["Always build request BarTypes with -EXTERNAL suffix","Aggregate internal bars from trades/quotes via Nautilus aggregators instead of venue requests","Standardize BarType construction helpers to avoid INTERNAL/EXTERNAL mixups"],"tags":["binance","bars","aggregation"],"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"}