{"record":{"id":"f71d0c7e3e93d24b","repo":"nautechsystems/nautilus_trader","slug":"okx-does-not-support-a-aggregation","errorCode":null,"errorMessage":"OKX does not support {a:?} aggregation","messagePattern":"OKX does not support (.+?) aggregation","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":3576,"sourceCode":"            return Ok(Vec::new());\n        }\n\n        if let Some(e) = end\n            && e > now\n        {\n            end = Some(now);\n        }\n\n        let spec = bar_type.spec();\n        let step = spec.step.get();\n        let bar_param = match spec.aggregation {\n            BarAggregation::Second => format!(\"{step}s\"),\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!(\"OKX does not support {a:?} aggregation\"),\n        };\n\n        let slot_ms: i64 = match spec.aggregation {\n            BarAggregation::Second => (step as i64) * 1_000,\n            BarAggregation::Minute => (step as i64) * 60_000,\n            BarAggregation::Hour => (step as i64) * 3_600_000,\n            BarAggregation::Day => (step as i64) * 86_400_000,\n            BarAggregation::Week => (step as i64) * 7 * 86_400_000,\n            BarAggregation::Month => (step as i64) * 30 * 86_400_000,\n            _ => unreachable!(\"Unsupported aggregation should have been caught above\"),\n        };\n        let slot_ns: i64 = slot_ms * 1_000_000;\n\n        let mode = match (start, end) {\n            (None, None) => Mode::Latest,\n            (Some(_), None) => Mode::Backward, // Changed: when only start is provided, work backward from now\n            (None, Some(_)) => Mode::Backward,\n            (Some(_), Some(_)) => Mode::Range,","sourceCodeStart":3558,"sourceCodeEnd":3594,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L3558-L3594","documentation":"When building OKX bar (candle) requests, the adapter maps Nautilus BarAggregation variants to OKX bar-size strings. Only Second, Minute, Hour, Day, Week, and Month aggregations are supported; any other aggregation (e.g. Tick, Volume) hits a catch-all arm and bails. OKX simply has no candle granularity corresponding to those aggregations.","triggerScenarios":"Requesting OKX historical bars (request_bars / bar subscription) with a BarSpec whose aggregation is Tick, Volume, Value, or another unsupported variant.","commonSituations":"Configuring a bar aggregator or data request with an aggregation type that works on other venues but not OKX; copy-pasted BarSpec from a crypto data provider that supports volume bars.","solutions":["Use one of Second/Minute/Hour/Day/Week/Month aggregations in the BarSpec","Aggregate ticks into time bars locally (via an internal aggregator) instead of asking OKX for tick/volume bars","Validate the BarSpec aggregation before submitting the request"],"exampleFix":"// before\nlet spec = BarSpecification::new(step, BarAggregation::Volume, price_type);\n// after\nlet spec = BarSpecification::new(step, BarAggregation::Minute, price_type);","handlingStrategy":"validation","validationCode":"match spec.aggregation {\n    BarAggregation::Second | BarAggregation::Minute | BarAggregation::Hour\n    | BarAggregation::Day | BarAggregation::Week | BarAggregation::Month => {}\n    other => return Err(anyhow::anyhow!(\"OKX does not support {other:?} aggregation\")),\n}","typeGuard":"fn okx_supported_aggregation(a: BarAggregation) -> bool {\n    matches!(a, BarAggregation::Second | BarAggregation::Minute\n        | BarAggregation::Hour | BarAggregation::Day\n        | BarAggregation::Week | BarAggregation::Month)\n}","tryCatchPattern":"if let Err(e) = client.request_bars(bar_type, ...).await {\n    log::error!(\"bar request rejected: {e}\");\n}","preventionTips":["Restrict OKX BarSpecs to time-based aggregations","Aggregate ticks or volume bars locally rather than requesting them from OKX","Validate BarSpec before registering subscriptions"],"tags":["okx","bars","unsupported","aggregation"],"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"}