{"record":{"id":"a0057512a913c4d5","repo":"nautechsystems/nautilus_trader","slug":"only-external-aggregation-is-supported-a00575","errorCode":null,"errorMessage":"Only EXTERNAL aggregation is supported","messagePattern":"Only EXTERNAL aggregation is supported","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/common/parse.rs","lineNumber":441,"sourceCode":"                }\n            } else {\n                // No market price available, default to SL for safety\n                HyperliquidExchangeTpSl::Sl\n            }\n        }\n    }\n}\n\n/// Converts a Nautilus `BarType` to a Hyperliquid bar interval.\n///\n/// # Errors\n///\n/// Returns an error if the bar type uses an unsupported aggregation or step value.\npub fn bar_type_to_interval(bar_type: &BarType) -> anyhow::Result<HyperliquidBarInterval> {\n    let spec = bar_type.spec();\n    let step = spec.step.get();\n\n    anyhow::ensure!(\n        bar_type.aggregation_source() == AggregationSource::External,\n        \"Only EXTERNAL aggregation is supported\"\n    );\n\n    let interval = match spec.aggregation {\n        BarAggregation::Minute => match step {\n            1 => OneMinute,\n            3 => ThreeMinutes,\n            5 => FiveMinutes,\n            15 => FifteenMinutes,\n            30 => ThirtyMinutes,\n            _ => anyhow::bail!(\"Unsupported minute step: {step}\"),\n        },\n        BarAggregation::Hour => match step {\n            1 => OneHour,\n            2 => TwoHours,\n            4 => FourHours,\n            8 => EightHours,","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/common/parse.rs#L423-L459","documentation":"Hyperliquid bars must be requested with EXTERNAL aggregation source: the adapter fetches pre-aggregated candles from the exchange HTTP API rather than aggregating ticks internally. bar_type_to_interval throws this error when a bar type with any other aggregation source (e.g. INTERNAL) is passed to request_bars, subscribe_bars, or unsubscribe_bars.","triggerScenarios":"Calling request_bars/subscribe_bars with a BarType whose aggregation_source is not AggregationSource::External — e.g. a bar type built with INTERNAL aggregation or with the wrong aggregation source specifier in the bar type string.","commonSituations":"Configuring strategy subscriptions with INTERNAL bar aggregation while using the Hyperliquid data client; copying bar-type strings from adapters that support internal aggregation; defaulting bar aggregation source in config without specifying External.","solutions":["Construct the BarType with AggregationSource::External (e.g. use 'BTC-PERP.HYPERLIQUID-1-MINUTE.EXTERNAL' style bar type strings)","Set the strategy/config to use external aggregation for Hyperliquid data subscriptions","If internal aggregation is required, use an aggregating data engine/adapter that supports it instead of the Hyperliquid adapter directly","Validate bar types at startup against bar_type.aggregation_source() before subscribing"],"exampleFix":"// before\nlet bar_type = BarType::new(instrument_id, BarAggregation::Minute, 1, AggregationSource::Internal);\n// after\nlet bar_type = BarType::new(instrument_id, BarAggregation::Minute, 1, AggregationSource::External);","handlingStrategy":"validation","validationCode":"if bar_type.aggregation_source() != AggregationSource::External {\n    return Err(anyhow!(\"Hyperliquid requires EXTERNAL aggregation, got {:?}\", bar_type.aggregation_source()));\n}\nclient.request_bars(bar_type)?;","typeGuard":"fn is_external_bar_type(bt: &BarType) -> bool {\n    bt.aggregation_source() == AggregationSource::External\n}","tryCatchPattern":"match bar_type_to_interval(&bar_type) {\n    Err(e) if e.to_string().contains(\"Only EXTERNAL aggregation\") => {\n        eprintln!(\"Rebuild bar_type with AggregationSource::External\");\n    }\n    Err(e) => return Err(e),\n    Ok(interval) => subscribe(interval),\n}","preventionTips":["Always specify .EXTERNAL in Hyperliquid bar type strings","Validate bar type aggregation source at strategy startup","Use an internal-aggregation-capable engine if INTERNAL bars are required"],"tags":["rust","hyperliquid","bars","configuration"],"backgroundTag":"unsupported-operation","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"}