{"record":{"id":"0a9e03c5213e935d","repo":"nautechsystems/nautilus_trader","slug":"invalid-barspecification-for-mark-price-channel","errorCode":null,"errorMessage":"Invalid `BarSpecification` for mark price channel, was {bar_spec}","messagePattern":"Invalid `BarSpecification` for mark price channel, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/parse.rs","lineNumber":1437,"sourceCode":"        BAR_SPEC_1_SECOND_LAST => OKXWsChannel::MarkPriceCandle1Second,\n        BAR_SPEC_1_MINUTE_LAST => OKXWsChannel::MarkPriceCandle1Minute,\n        BAR_SPEC_3_MINUTE_LAST => OKXWsChannel::MarkPriceCandle3Minute,\n        BAR_SPEC_5_MINUTE_LAST => OKXWsChannel::MarkPriceCandle5Minute,\n        BAR_SPEC_15_MINUTE_LAST => OKXWsChannel::MarkPriceCandle15Minute,\n        BAR_SPEC_30_MINUTE_LAST => OKXWsChannel::MarkPriceCandle30Minute,\n        BAR_SPEC_1_HOUR_LAST => OKXWsChannel::MarkPriceCandle1Hour,\n        BAR_SPEC_2_HOUR_LAST => OKXWsChannel::MarkPriceCandle2Hour,\n        BAR_SPEC_4_HOUR_LAST => OKXWsChannel::MarkPriceCandle4Hour,\n        BAR_SPEC_6_HOUR_LAST => OKXWsChannel::MarkPriceCandle6Hour,\n        BAR_SPEC_12_HOUR_LAST => OKXWsChannel::MarkPriceCandle12Hour,\n        BAR_SPEC_1_DAY_LAST => OKXWsChannel::MarkPriceCandle1Day,\n        BAR_SPEC_2_DAY_LAST => OKXWsChannel::MarkPriceCandle2Day,\n        BAR_SPEC_3_DAY_LAST => OKXWsChannel::MarkPriceCandle3Day,\n        BAR_SPEC_5_DAY_LAST => OKXWsChannel::MarkPriceCandle5Day,\n        BAR_SPEC_1_WEEK_LAST => OKXWsChannel::MarkPriceCandle1Week,\n        BAR_SPEC_1_MONTH_LAST => OKXWsChannel::MarkPriceCandle1Month,\n        BAR_SPEC_3_MONTH_LAST => OKXWsChannel::MarkPriceCandle3Month,\n        _ => anyhow::bail!(\"Invalid `BarSpecification` for mark price channel, was {bar_spec}\"),\n    };\n    Ok(channel)\n}\n\n/// Converts Nautilus bar specification to OKX timeframe string.\n///\n/// # Errors\n///\n/// Returns an error if the bar specification does not have a corresponding\n/// OKX timeframe value.\npub fn bar_spec_as_okx_timeframe(bar_spec: BarSpecification) -> anyhow::Result<&'static str> {\n    let timeframe = match bar_spec {\n        BAR_SPEC_1_SECOND_LAST => \"1s\",\n        BAR_SPEC_1_MINUTE_LAST => \"1m\",\n        BAR_SPEC_3_MINUTE_LAST => \"3m\",\n        BAR_SPEC_5_MINUTE_LAST => \"5m\",\n        BAR_SPEC_15_MINUTE_LAST => \"15m\",\n        BAR_SPEC_30_MINUTE_LAST => \"30m\",","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/parse.rs#L1419-L1455","documentation":"bar_spec_as_okx_mark_price_channel maps a Nautilus BarSpecification to an OKX mark-price candle websocket channel. The mark-price candle table is smaller than the regular candle table (it stops at 3M and has no 6M/1Y entries), so unsupported specs — including 6M/12M that work for regular candles — bail with this message.","triggerScenarios":"Subscribing to OKX mark-price bars with a BarSpecification not in the table: 6M or 12M intervals (supported for regular candles but not mark-price), non-LAST price types, or non-time aggregations such as tick/volume bars.","commonSituations":"Reusing the same bar spec for both regular and mark-price candle subscriptions and assuming identical support; upgrading OKX interval support and trying newer intervals for mark-price candles; typo'd aggregation config.","solutions":["Verify the bar spec against bar_spec_as_okx_mark_price_channel's supported list (1m..1D, 2D/3D/5D/1W/1M/3M, LAST)","Use a supported mark-price interval such as BAR_SPEC_1_HOUR_LAST instead of 6M/12M","If only regular candles were intended, use the standard candle channel rather than the mark-price one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let channel = bar_spec_as_okx_mark_price_channel(bar_type.spec())\n    .or_else(|_| bar_spec_as_okx_channel(bar_type.spec()));\nif channel.is_err() {\n    eprintln!(\"spec {} unsupported for mark-price candles\", bar_type.spec());\n}","typeGuard":null,"tryCatchPattern":"match bar_spec_as_okx_mark_price_channel(&spec) {\n    Ok(ch) => subscribe(ch),\n    Err(e) => log::warn!(\"falling back to regular candles: {e}\"),\n}","preventionTips":["Remember mark-price candles support fewer intervals (no 6M/12M) than regular candles","Keep separate config entries for regular vs mark-price bar specs","Use LAST price type for all candle subscriptions"],"tags":["rust","okx","adapter","bars","mark-price"],"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"}