{"record":{"id":"adfaf8ca5f28c63d","repo":"nautechsystems/nautilus_trader","slug":"derive-only-supports-external-aggregation-source","errorCode":null,"errorMessage":"Derive only supports EXTERNAL aggregation source (got {bar_type})","messagePattern":"Derive only supports EXTERNAL aggregation source \\(got (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/derive/src/data.rs","lineNumber":1317,"sourceCode":"                updates,\n                start_nanos,\n                end_nanos,\n                clock.get_time_ns(),\n                params,\n            ));\n\n            if let Err(e) = sender.send(DataEvent::Response(response)) {\n                log::error!(\"Failed to send Derive funding rates response: {e}\");\n            }\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn request_bars(&self, request: RequestBars) -> anyhow::Result<()> {\n        let bar_type = request.bar_type;\n        anyhow::ensure!(\n            bar_type.aggregation_source() == AggregationSource::External,\n            \"Derive only supports EXTERNAL aggregation source (got {bar_type})\",\n        );\n        let spec = bar_type.spec();\n        anyhow::ensure!(\n            spec.price_type == PriceType::Last,\n            \"Derive candles are trade-based; only PriceType::Last is supported (got {bar_type})\",\n        );\n\n        let instrument_id = bar_type.instrument_id();\n        let instrument = self\n            .instruments\n            .get_cloned(&instrument_id)\n            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;\n        let venue_symbol = format_venue_symbol(&instrument_id)?.to_string();\n        let price_precision = instrument.price_precision();\n        let size_precision = instrument.size_precision();\n","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/data.rs#L1299-L1335","documentation":"`request_bars` for the Derive adapter only supports bars aggregated externally (i.e. the adapter fetches provider candles, not Nautilus-built ones). It throws via `anyhow::ensure!` when the `BarType`'s aggregation source is not `AggregationSource::External`.","triggerScenarios":"Calling `request_bars` with a `BarType` created with `AggregationSource::Internal` (e.g. `BarType::new(id, spec, AggregationSource::Internal)`), which would require Nautilus-side tick aggregation that Derive does not serve.","commonSituations":"Bar specs copied from adapters that support internal aggregation; strategy configs defining internal bars; docs/examples from other venues pasted into a Derive config.","solutions":["Construct the BarType with `AggregationSource::External`, e.g. `BarType::new(instrument_id, spec, AggregationSource::External)`.","Update strategy/config bar definitions to specify EXTERNAL aggregation for Derive.","If internal aggregation is required, feed Derive trade data and aggregate locally instead of using request_bars.","Log the bar_type in the error message to spot which definition is wrong."],"exampleFix":"// before\nlet bar_type = BarType::new(instrument_id, BarSpecification::new(1, BarAggregation::Minute, PriceType::Last), AggregationSource::Internal);\n// after\nlet bar_type = BarType::new(instrument_id, BarSpecification::new(1, BarAggregation::Minute, PriceType::Last), AggregationSource::External);","handlingStrategy":"validation","validationCode":"// Rust\nif bar_type.aggregation_source() != AggregationSource::External {\n    return Err(anyhow!(\"Derive requires EXTERNAL aggregation: {bar_type}\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.request_bars(req) {\n    if e.to_string().contains(\"EXTERNAL aggregation\") {\n        // rebuild request with AggregationSource::External\n    }\n}","preventionTips":["Define Derive bar types with AggregationSource::External.","Centralize BarType construction in one helper per venue.","Review strategy configs for internal aggregation leftovers.","Test bar requests against each adapter's supported sources."],"tags":["bars","aggregation-source","derive","validation"],"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-14T05:17:10.506Z"}