{"record":{"id":"b9eb4564549d9d9f","repo":"nautechsystems/nautilus_trader","slug":"invalid-tp-order-type-was-other","errorCode":null,"errorMessage":"invalid `tp_order_type`, was {other}","messagePattern":"invalid `tp_order_type`, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/factories/order.rs","lineNumber":1661,"sourceCode":"                    true,  // reduce_only\n                    quote_quantity,\n                    None, // display_qty\n                    emulation_trigger,\n                    trigger_instrument_id,\n                    tp_contingency_type,\n                    tp_order_list_id,\n                    tp_linked_order_ids,\n                    tp_parent_order_id,\n                    tp_exec_algorithm_id,\n                    tp_exec_algorithm_params,\n                    tp_exec_spawn_id,\n                    tp_tags,\n                    UUID4::new(),\n                    ts_init,\n                )?;\n                OrderAny::TrailingStopLimit(order)\n            }\n            other => anyhow::bail!(\"invalid `tp_order_type`, was {other}\"),\n        };\n\n        let sl_contingency_type = Some(contingency_type);\n        let sl_order_list_id = Some(order_list_id);\n        let sl_linked_order_ids = Some(vec![tp_client_order_id]);\n        let sl_parent_order_id = Some(entry_client_order_id);\n\n        let sl_order = match sl_order_type {\n            OrderType::StopMarket => OrderAny::StopMarket(StopMarketOrder::new_checked(\n                self.trader_id,\n                self.strategy_id,\n                instrument_id,\n                sl_client_order_id,\n                sl_tp_side,\n                quantity,\n                required(\n                    sl_trigger_price,\n                    \"`sl_trigger_price` is required for a STOP_MARKET stop-loss\",","sourceCodeStart":1643,"sourceCodeEnd":1679,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/factories/order.rs#L1643-L1679","documentation":"In `try_bracket`, the take-profit leg is constructed by matching on `tp_order_type`; only order types supported as a TP contingency (typically limit, stop-limit, and related) are handled. Any other variant reaches the catch-all arm and bails with this error, so the requested take-profit order type cannot form a valid bracket.","triggerScenarios":"Calling `factory.bracket(...)` with a `tp_order_type` that is not one of the supported take-profit variants — e.g. TRAILING_STOP_MARKET or a market/stop-market type where the factory expects limit-family types for the TP leg.","commonSituations":"Strategy configs where the TP type is user-supplied and unchecked; copying SL-type settings into the TP slot; library version changes adding order types that the bracket factory does not yet support for TP legs.","solutions":["Use a supported take-profit order type (e.g. limit or stop-limit) for the TP leg.","Validate tp_order_type against the supported set before calling bracket().","If a trailing/stop TP is needed, build the orders manually (entry + separate contingent orders) instead of via bracket().","Check the library version's bracket documentation for exactly which OrderType values are accepted for tp_order_type."],"exampleFix":"// before\nlet orders = factory.bracket(tp_order_type = OrderType::TrailingStopMarket, ...)?;\n\n// after\nlet tp_order_type = OrderType::Limit; // supported TP leg\nlet orders = factory.bracket(tp_order_type = tp_order_type, ...)?;","handlingStrategy":"validation","validationCode":"const SUPPORTED_TP: &[OrderType] = &[\n    OrderType::Limit, OrderType::StopLimit,\n];\nif !SUPPORTED_TP.contains(&tp_order_type) {\n    return Err(anyhow::anyhow!(\n        \"unsupported bracket tp_order_type: {tp_order_type:?}\"\n    ));\n}","typeGuard":"fn is_valid_bracket_tp(t: OrderType) -> bool {\n    matches!(t, OrderType::Limit | OrderType::StopLimit)\n}","tryCatchPattern":"match factory.bracket(tp_order_type = tp_order_type, ...) {\n    Ok(orders) => orders,\n    Err(e) if e.to_string().contains(\"invalid `tp_order_type`\") => {\n        bail!(\"bracket TP type {tp_order_type:?} unsupported; use Limit/StopLimit\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Do not reuse stop-leg order type settings for the TP leg.","Validate user-supplied TP order type from config before building the bracket.","Cover the supported TP-type set with a unit test on the bracket factory."],"tags":["rust","orders","enum","validation"],"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"}