{"record":{"id":"0d5e5314ce40a1e9","repo":"nautechsystems/nautilus_trader","slug":"invalid-ordertype-cannot-be-represented-on-okx","errorCode":null,"errorMessage":"Invalid `OrderType` cannot be represented on OKX: {value:?}","messagePattern":"Invalid `OrderType` cannot be represented on OKX: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/enums.rs","lineNumber":1333,"sourceCode":"        }\n    }\n}\n\nimpl From<OrderType> for OKXOrderType {\n    fn from(value: OrderType) -> Self {\n        match value {\n            OrderType::Market => Self::Market,\n            OrderType::Limit => Self::Limit,\n            OrderType::MarketToLimit => Self::Ioc,\n            // Conditional orders will be handled separately via algo orders\n            OrderType::StopMarket\n            | OrderType::StopLimit\n            | OrderType::MarketIfTouched\n            | OrderType::LimitIfTouched\n            | OrderType::TrailingStopMarket => {\n                panic!(\"Conditional order types must use OKXAlgoOrderType\")\n            }\n            _ => panic!(\"Invalid `OrderType` cannot be represented on OKX: {value:?}\"),\n        }\n    }\n}\n\nimpl From<PositionSide> for OKXPositionSide {\n    fn from(value: PositionSide) -> Self {\n        match value {\n            PositionSide::Long => Self::Long,\n            PositionSide::Short => Self::Short,\n            PositionSide::Flat => Self::None,\n        }\n    }\n}\n\n#[derive(\n    Copy,\n    Clone,\n    Debug,","sourceCodeStart":1315,"sourceCodeEnd":1351,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/enums.rs#L1315-L1351","documentation":"This is the catch-all arm of the same From<OrderType> conversion for OKX: any OrderType not explicitly mapped (and not one of the conditional types) cannot be represented on OKX, so the conversion panics with the debug-formatted value. It indicates an unmapped or invalid core order type reached the OKX adapter.","triggerScenarios":"Converting an OrderType variant with no OKX equivalent (e.g. a newly added core enum variant, or an invalid/default value) into OKXOrderType during order request building.","commonSituations":"Core enum gained a new variant the adapter was not updated for; corrupted or deserialized-invalid OrderType values flowing from strategy logic; version mismatch between core crate and OKX adapter crate.","solutions":["Use an OrderType the OKX adapter explicitly supports (Market, Limit, and mapped variants)","Update/align the core nautilus crate and OKX adapter versions so all variants are mapped","Add a match arm mapping the new variant if OKX supports it","Pre-validate OrderType against the adapter's supported set before submission"],"exampleFix":"// before\nlet okx_type = OKXOrderType::from(order_type); // panics for unmapped variant\n// after\nmatch order_type {\n    OrderType::Market | OrderType::Limit => OKXOrderType::from(order_type),\n    _ => return Err(\"order type not supported on OKX\"),\n}","handlingStrategy":"validation","validationCode":"fn is_okx_supported(t: &OrderType) -> bool {\n    matches!(t, OrderType::Market | OrderType::Limit | OrderType::StopMarket | OrderType::StopLimit | OrderType::MarketIfTouched | OrderType::LimitIfTouched | OrderType::TrailingStopMarket)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin core and adapter crate versions so OrderType variants stay in sync","Add exhaustive-match tests covering every OrderType for each venue adapter","Reject unsupported order types at the strategy/risk layer with a logged error instead of letting them reach the adapter"],"tags":["rust","panic","okx","order-type","enum-conversion"],"backgroundTag":"invalid-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"}