{"record":{"id":"04c6b4257d82451d","repo":"nautechsystems/nautilus_trader","slug":"take-profit-market-order-missing-trigger-price","errorCode":null,"errorMessage":"Take profit market order missing trigger_price","messagePattern":"Take profit market order missing trigger_price","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/execution/mod.rs","lineNumber":1509,"sourceCode":"                        let msg = order_builder.build_stop_limit_order(\n                            instrument_id,\n                            client_id_u32,\n                            client_metadata,\n                            order.order_side(),\n                            trigger_price,\n                            limit_price,\n                            order.quantity(),\n                            order.time_in_force(),\n                            order.is_post_only(),\n                            order.is_reduce_only(),\n                            cond_expire,\n                        )?;\n                        (msg, \"stop_limit\")\n                    }\n                    // dYdX TakeProfitMarket maps to Nautilus MarketIfTouched\n                    OrderType::MarketIfTouched => {\n                        let trigger_price = order.trigger_price().ok_or_else(|| {\n                            anyhow::anyhow!(\"Take profit market order missing trigger_price\")\n                        })?;\n                        let cond_expire = order.expire_time().map(nanos_to_secs_i64);\n                        let msg = order_builder.build_take_profit_market_order(\n                            instrument_id,\n                            client_id_u32,\n                            client_metadata,\n                            order.order_side(),\n                            trigger_price,\n                            order.quantity(),\n                            order.is_reduce_only(),\n                            cond_expire,\n                        )?;\n                        (msg, \"take_profit_market\")\n                    }\n                    // dYdX TakeProfitLimit maps to Nautilus LimitIfTouched\n                    OrderType::LimitIfTouched => {\n                        let trigger_price = order.trigger_price().ok_or_else(|| {\n                            anyhow::anyhow!(\"Take profit limit order missing trigger_price\")","sourceCodeStart":1491,"sourceCodeEnd":1527,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/execution/mod.rs#L1491-L1527","documentation":"Nautilus MarketIfTouched orders map to dYdX TAKE_PROFIT_MARKET conditional orders, which require a trigger_price. When building the take-profit-market message the client reads order.trigger_price() and throws this error if it is None, since the exchange cannot activate the order without a trigger level.","triggerScenarios":"Submitting a MarketIfTouched order whose trigger_price was never set (factory call omitted trigger_price, or a plain market order repurposed as MIT).","commonSituations":"order_factory.market_if_touched call missing trigger_price; strategy computing the trigger conditionally and passing None; orders deserialized without the trigger field.","solutions":["Set trigger_price when creating the MarketIfTouched order","Validate trigger_price is present before submit","Remember the mapping: Nautilus MarketIfTouched == dYdX TakeProfitMarket, both need a trigger"],"exampleFix":"// before\nlet order = factory.market_if_touched(id, side, qty, None); // trigger missing\n// after\nlet order = factory.market_if_touched(id, side, qty, Some(trigger_price));","handlingStrategy":"validation","validationCode":"if order.order_type() == OrderType::MarketIfTouched && order.trigger_price().is_none() {\n    return Err(\"MarketIfTouched (dYdX take-profit market) requires a trigger_price\".into());\n}","typeGuard":"fn has_trigger(order: &OrderAny) -> bool { order.trigger_price().is_some() }","tryCatchPattern":"if let Err(e) = client.submit_order(order).await {\n    if e.to_string().contains(\"missing trigger_price\") {\n        // repair the order construction; retry is futile\n    }\n}","preventionTips":["Supply trigger_price in every market_if_touched factory call","Document the Nautilus->dYdX mapping (MarketIfTouched = TakeProfitMarket) where orders are built","Add a pre-submit validator covering all conditional order types"],"tags":["rust","orders","conditional-orders","dydx"],"backgroundTag":"missing-required-argument","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"}