{"record":{"id":"f21206249f9c8d4c","repo":"nautechsystems/nautilus_trader","slug":"unsupported-okx-order-type-e","errorCode":null,"errorMessage":"Unsupported OKX order type: {e}","messagePattern":"Unsupported OKX order type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/parse.rs","lineNumber":154,"sourceCode":"pub fn determine_order_type_with_alt(\n    okx_ord_type: OKXOrderType,\n    px: &str,\n    px_vol: &str,\n    px_usd: &str,\n) -> anyhow::Result<OrderType> {\n    match okx_ord_type {\n        OKXOrderType::OpFok => Ok(OrderType::Limit),\n        OKXOrderType::Fok | OKXOrderType::Ioc | OKXOrderType::OptimalLimitIoc => {\n            let has_alt_price = !px_vol.is_empty() || !px_usd.is_empty();\n            if has_alt_price || !is_market_price(px) {\n                Ok(OrderType::Limit)\n            } else {\n                Ok(OrderType::Market)\n            }\n        }\n        other => other\n            .try_into()\n            .map_err(|e| anyhow::anyhow!(\"Unsupported OKX order type: {e}\")),\n    }\n}\n\n/// Deserializes a string into `Option<OKXTargetCurrency>`, treating empty strings as `None`.\n///\n/// # Errors\n///\n/// Returns an error if the string cannot be parsed into an `OKXTargetCurrency`.\npub fn deserialize_target_currency_as_none<'de, D>(\n    deserializer: D,\n) -> Result<Option<OKXTargetCurrency>, D::Error>\nwhere\n    D: Deserializer<'de>,\n{\n    let s = String::deserialize(deserializer)?;\n    if s.is_empty() {\n        Ok(None)\n    } else {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/parse.rs#L136-L172","documentation":"determine_order_type_with_alt maps OKX's order type string onto NautilusTrader's OrderType. Known strings are handled directly; any other string goes through TryInto<OrderType>, which rejects unrecognized OKX ordType values, and the failure is wrapped in this 'Unsupported OKX order type' anyhow error.","triggerScenarios":"determine_order_type or parse_order_status_report receives an OKX order whose ordType is not one of the recognized values (limit/post_only/fok/ioc/market/optimal_limit_ioc etc.) — e.g. a new or algo order type string OKX introduced or an algo variant like 'trigger'/'move_order_stop' flowing through this path.","commonSituations":"OKX adds a new ordType in an API update while the adapter pins an older enum; using algo-order endpoints whose result types aren't handled; regional OKX deployments (e.g. OKX Jump Trading/derivatives variants) emitting extra type strings; stale adapter version after an exchange API change.","solutions":["Update the adapter/OKX enum definitions to the latest version so newly introduced ordType strings are recognized.","Log the raw ordType value that failed TryInto so you know exactly which string is missing from the mapping.","Extend the mapping (or the TryFrom impl for OrderType) to cover the new OKX ordType with the closest Nautilus OrderType.","As a stopgap, treat unknown types as skipped order reports with a warning rather than erroring the whole parse."],"exampleFix":"// before\nother => other\n    .try_into()\n    .map_err(|e| anyhow::anyhow!(\"Unsupported OKX order type: {e}\")),\n\n// after\n\"trigger\" => Ok(OrderType::StopMarket), // map newly seen OKX ordType explicitly\nother => other\n    .try_into()\n    .map_err(|e| anyhow::anyhow!(\"Unsupported OKX order type: {e}\")),","handlingStrategy":"try-catch","validationCode":"const KNOWN_OKX_ORDERTYPES: &[&str] = &[\"limit\", \"post_only\", \"fok\", \"ioc\", \"market\", \"optimal_limit_ioc\"];\nfn is_known_ord_type(t: &str) -> bool { KNOWN_OKX_ORDERTYPES.contains(&t) }","typeGuard":null,"tryCatchPattern":"match determine_order_type(&report) {\n    Ok(t) => t,\n    Err(e) => { log::warn!(\"{} — skipping report\", e); return Ok(None); }\n}","preventionTips":["Keep the OKX adapter updated for new ordType values introduced by the exchange.","Log unrecognized raw ordType strings to extend mappings quickly.","Prefer placing orders through the adapter itself so only supported types are created."],"tags":["rust","okx","orders","enum-mapping"],"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-14T00:17:10.932Z"}