{"record":{"id":"fc79097e2c351673","repo":"nautechsystems/nautilus_trader","slug":"unsupported-okx-order-type-e-fc7909","errorCode":null,"errorMessage":"Unsupported OKX order type: {e}","messagePattern":"Unsupported OKX order type: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/websocket/parse.rs","lineNumber":1754,"sourceCode":"    let order_type = match okx_order_type {\n        OKXOrderType::Trigger => {\n            if is_market_price(&msg.px) {\n                OrderType::StopMarket\n            } else {\n                OrderType::StopLimit\n            }\n        }\n        OKXOrderType::Fok | OKXOrderType::Ioc | OKXOrderType::OptimalLimitIoc => {\n            determine_order_type_with_alt(\n                okx_order_type,\n                &msg.px,\n                msg.px_vol.as_deref().unwrap_or(\"\"),\n                msg.px_usd.as_deref().unwrap_or(\"\"),\n            )?\n        }\n        other => other\n            .try_into()\n            .map_err(|e| anyhow::anyhow!(\"Unsupported OKX order type: {e}\"))?,\n    };\n    let order_status: OrderStatus = msg\n        .state\n        .try_into()\n        .map_err(|e| anyhow::anyhow!(\"Unsupported OKX order status: {e}\"))?;\n\n    let time_in_force = match okx_order_type {\n        OKXOrderType::Fok | OKXOrderType::OpFok => TimeInForce::Fok,\n        OKXOrderType::Ioc | OKXOrderType::OptimalLimitIoc => TimeInForce::Ioc,\n        _ => TimeInForce::Gtc,\n    };\n\n    let size_precision = instrument.size_precision();\n\n    // Parse quantities based on target currency\n    // OKX always returns acc_fill_sz in base currency, but sz depends on tgt_ccy\n\n    // Determine if this is a quote-quantity order","sourceCodeStart":1736,"sourceCodeEnd":1772,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/websocket/parse.rs#L1736-L1772","documentation":"parse_order_status_report converts an OKX WebSocket order message into a Nautilus OrderStatusReport. For order types not handled by the special Trigger/FOK/IOC branches it falls back to `OKXOrderType::try_into(OrderType)`; when the OKX ordType value has no Nautilus OrderType mapping, the conversion fails and this error wraps it. It means the adapter received (or the tests fed) an OKX order type the adapter does not yet support.","triggerScenarios":"An order-status update (orders channel or order-message parse path) whose `ordType` deserialized to an OKXOrderType variant for which `TryInto<OrderType>` returns Err — i.e. any ordType outside the mapped set (limit, post_only, fok, ioc, trigger, optimal_limit_ioc handled paths). Also triggered directly by unit tests passing synthetic OKXOrderType values.","commonSituations":"OKX adds a new ordType value (API version change) that serde deserializes into an unmapped variant; a user places an order kind (e.g. TWAP/iceberg variants) through the OKX web UI or another client and nautilus receives its status updates; running a stale adapter against a newer OKX API.","solutions":["Log/inspect the raw msg.ordType string to identify the unmapped OKX order type.","Check the OKXOrderType enum and its TryInto<OrderType> impl in the okx adapter for a missing mapping; add the variant mapping if OKX introduced a new ordType.","Update the okx adapter dependency / upgrade nautilus to a version that maps the new ordType.","As a workaround, filter or cancel unsupported order types at the venue so their status updates never reach the parser."],"exampleFix":"// before (parse.rs:1752)\nother => other.try_into().map_err(|e| anyhow::anyhow!(\"Unsupported OKX order type: {e}\"))?,\n\n// after (add mapping in OKXOrderType TryInto<OrderType> impl)\nOKXOrderType::NewVariant => Ok(OrderType::Limit), // map the newly added OKX ordType\n// or, defensively:\nother => other.try_into().map_err(|e| {\n    tracing::error!(ord_type = %msg.ord_type, \"Unsupported OKX order type: {e}\");\n    anyhow::anyhow!(\"Unsupported OKX order type: {e}\")\n})?,","handlingStrategy":"try-catch","validationCode":"// Rust: validate ordType before relying on the report\nfn is_supported_order_type(t: &OKXOrderType) -> bool {\n    matches!(\n        t,\n        OKXOrderType::Limit\n            | OKXOrderType::PostOnly\n            | OKXOrderType::Fok\n            | OKXOrderType::Ioc\n            | OKXOrderType::Market\n            | OKXOrderType::Trigger\n            | OKXOrderType::OpFok\n            | OKXOrderType::OptimalLimitIoc\n    )\n}","typeGuard":"fn supported_order_type(t: &OKXOrderType) -> Option<OrderType> {\n    OrderType::try_from(*t).ok()\n}","tryCatchPattern":"match parse_order_status_report(&msg, &instrument, account_id, ts_init) {\n    Ok(report) => handle(report),\n    Err(e) if e.to_string().contains(\"Unsupported OKX order type\") => {\n        tracing::warn!(ord_id = %msg.ord_id, \"skipping order with unsupported type: {e:#}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the okx adapter on a version matching the live OKX API ordType set.","Exhaustively match OKXOrderType in custom code so new variants fail at compile time.","Log unknown ordType strings at the deserialization boundary to detect OKX API additions early.","Avoid placing exotic order types (TWAP etc.) outside nautilus if you reconcile its status stream."],"tags":["rust","okx","websocket","order-parsing","unsupported-enum-value"],"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"}