{"record":{"id":"c603dcda134ef4db","repo":"nautechsystems/nautilus_trader","slug":"conditional-order-types-must-use-okxalgoordertype","errorCode":null,"errorMessage":"Conditional order types must use OKXAlgoOrderType","messagePattern":"Conditional order types must use OKXAlgoOrderType","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/enums.rs","lineNumber":1331,"sourceCode":"            OKXOrderType::Trigger => Ok(Self::StopMarket),\n            OKXOrderType::Other => Err(value),\n        }\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,","sourceCodeStart":1313,"sourceCodeEnd":1349,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/enums.rs#L1313-L1349","documentation":"On OKX, conditional order types (stop, take-profit, trailing) are submitted through a separate algo-order API using OKXAlgoOrderType. The From<OrderType> conversion for regular orders deliberately panics when handed a conditional type, telling you to use OKXAlgoOrderType instead. It guards against silently mis-mapping trigger orders onto the plain order endpoint.","triggerScenarios":"Converting OrderType::StopMarket, StopLimit, MarketIfTouched, LimitIfTouched, or TrailingStopMarket into the OKX order-type enum during regular order request construction.","commonSituations":"A strategy emits conditional orders and the execution client funnels them through the standard order submission path; porting code from another venue where conditional types are ordinary order params.","solutions":["Convert conditional order types to OKXAlgoOrderType and submit via the algo-order request path","Check the OrderType before submission and branch: regular types via the standard conversion, conditional via algo orders","If the order was not intended to be conditional, use Market or Limit instead"],"exampleFix":"// before\nlet okx_type = OKXOrderType::from(OrderType::StopMarket); // panics\n// after\nlet okx_algo = OKXAlgoOrderType::from(OrderType::StopMarket); // submit as algo order","handlingStrategy":"validation","validationCode":"const OKX_ALGO_TYPES: &[OrderType] = &[\n    OrderType::StopMarket, OrderType::StopLimit,\n    OrderType::MarketIfTouched, OrderType::LimitIfTouched,\n    OrderType::TrailingStopMarket,\n];\nfn needs_algo_path(t: &OrderType) -> bool { OKX_ALGO_TYPES.contains(t) }","typeGuard":"fn is_conditional_okx(t: &OrderType) -> bool {\n    matches!(t, OrderType::StopMarket | OrderType::StopLimit | OrderType::MarketIfTouched | OrderType::LimitIfTouched | OrderType::TrailingStopMarket)\n}","tryCatchPattern":null,"preventionTips":["Split order submission into regular and algo paths and dispatch on OrderType early","Never pass conditional OrderTypes through the plain OKX order conversion","Keep OKXAlgoOrderType mappings in sync with core OrderType variants"],"tags":["rust","panic","okx","algo-orders","order-type"],"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"}