{"record":{"id":"288b64d7d139e57f","repo":"nautechsystems/nautilus_trader","slug":"not-a-conditional-order-type-order-type","errorCode":null,"errorMessage":"Not a conditional order type: {order_type:?}","messagePattern":"Not a conditional order type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/enums.rs","lineNumber":1398,"sourceCode":"\n/// Returns whether an order type requires the advance algo cancel endpoint.\npub fn is_advance_algo_order(order_type: OrderType) -> bool {\n    OKX_ADVANCE_ALGO_ORDER_TYPES.contains(&order_type)\n}\n\n/// Converts Nautilus conditional order types to OKX algo order type.\n///\n/// # Errors\n///\n/// Returns an error if the provided `order_type` is not a conditional order type.\npub fn conditional_order_to_algo_type(order_type: OrderType) -> anyhow::Result<OKXAlgoOrderType> {\n    match order_type {\n        OrderType::StopMarket\n        | OrderType::StopLimit\n        | OrderType::MarketIfTouched\n        | OrderType::LimitIfTouched => Ok(OKXAlgoOrderType::Trigger),\n        OrderType::TrailingStopMarket => Ok(OKXAlgoOrderType::MoveOrderStop),\n        _ => anyhow::bail!(\"Not a conditional order type: {order_type:?}\"),\n    }\n}\n\n/// Represents the state of an algo (trigger/OCO/conditional) order on OKX.\n#[derive(\n    Copy,\n    Clone,\n    Debug,\n    Display,\n    PartialEq,\n    Eq,\n    Hash,\n    AsRefStr,\n    EnumIter,\n    EnumString,\n    Serialize,\n    Deserialize,\n)]","sourceCodeStart":1380,"sourceCodeEnd":1416,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/enums.rs#L1380-L1416","documentation":"conditional_order_to_algo_type maps Nautilus conditional order types (StopMarket, StopLimit, MarketIfTouched, LimitIfTouched to Trigger; TrailingStopMarket to MoveOrderStop) to OKX algo order types; any other OrderType falls through to the wildcard arm and is rejected, because plain orders must not be routed through the algo-order API.","triggerScenarios":"Calling submit_algo_order / place_algo_order_with_domain_types with a non-conditional OrderType such as OrderType::Limit, OrderType::Market, or an unmapped type like TrailingStopLimit.","commonSituations":"Misrouting regular orders into the algo submission path; using an order type the adapter has not mapped; factory code choosing order types dynamically.","solutions":["Route only conditional types (StopMarket, StopLimit, MarketIfTouched, LimitIfTouched, TrailingStopMarket) through the algo-order path","Submit plain Limit/Market orders via the normal place_order path","Extend the mapping if a new conditional type (e.g. TrailingStopLimit) needs OKX algo support"],"exampleFix":"// before\nsubmit_algo_order(order_factory.limit(...)) // non-conditional type\n// after\nsubmit_order(order_factory.limit(...))","handlingStrategy":"type-guard","validationCode":"// Rust\nfn is_okx_conditional(order_type: OrderType) -> bool {\n    matches!(order_type,\n        OrderType::StopMarket | OrderType::StopLimit\n        | OrderType::MarketIfTouched | OrderType::LimitIfTouched\n        | OrderType::TrailingStopMarket)\n}\nassert!(is_okx_conditional(order.order_type()), \"route plain orders via submit_order\");","typeGuard":"fn is_conditional(t: OrderType) -> bool {\n    matches!(t, OrderType::StopMarket | OrderType::StopLimit\n        | OrderType::MarketIfTouched | OrderType::LimitIfTouched\n        | OrderType::TrailingStopMarket)\n}","tryCatchPattern":null,"preventionTips":["Branch on order type before choosing algo vs regular submission","Keep an exhaustive test over OrderType variants for OKX mapping","Never hard-code algo-path submission for all orders"],"tags":["rust","okx","algo-orders","order-type"],"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-14T05:17:10.506Z"}