{"record":{"id":"fd226928c76c6c25","repo":"nautechsystems/nautilus_trader","slug":"take-profit-buy-trigger-price-trigger-price-mu","errorCode":null,"errorMessage":"Take profit buy trigger_price ({trigger_price}) must be <= limit price ({price})","messagePattern":"Take profit buy trigger_price \\((.+?)\\) must be <= limit price \\((.+?)\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/http/parse.rs","lineNumber":266,"sourceCode":"            match side {\n                OrderSide::Buy if trigger_price < price => {\n                    anyhow::bail!(\n                        \"Stop buy trigger_price ({trigger_price}) must be >= limit price ({price})\"\n                    );\n                }\n                OrderSide::Sell if trigger_price > price => {\n                    anyhow::bail!(\n                        \"Stop sell trigger_price ({trigger_price}) must be <= limit price ({price})\"\n                    );\n                }\n                _ => {}\n            }\n        }\n        DydxOrderType::TakeProfitLimit | DydxOrderType::TakeProfitMarket => {\n            // Take profit: trigger when price rises (sell) or falls (buy)\n            match side {\n                OrderSide::Buy if trigger_price > price => {\n                    anyhow::bail!(\n                        \"Take profit buy trigger_price ({trigger_price}) must be <= limit price ({price})\"\n                    );\n                }\n                OrderSide::Sell if trigger_price < price => {\n                    anyhow::bail!(\n                        \"Take profit sell trigger_price ({trigger_price}) must be >= limit price ({price})\"\n                    );\n                }\n                _ => {}\n            }\n        }\n        _ => {}\n    }\n\n    Ok(())\n}\n\n/// Parses a dYdX perpetual market into a Nautilus [`InstrumentAny`].","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/http/parse.rs#L248-L284","documentation":"For dYdX take-profit orders (TakeProfitLimit/TakeProfitMarket) on the buy side, the trigger price must be at or below the limit price — a buy take-profit triggers on downward movement (profitable for a short position). `validate_conditional_order` throws this error when `trigger_price > price` for a buy take-profit order.","triggerScenarios":"Calling `validate_conditional_order` via order submission with a TakeProfitLimit or TakeProfitMarket buy order whose trigger price is above the limit price.","commonSituations":"Applying stop-order trigger intuition (trigger above for buy) to take-profit orders; generating take-profit levels with sign/side confusion in strategy code.","solutions":["Lower the trigger price so it is <= the limit price for buy take-profit orders","Use the sell side if the take-profit should trigger on a price rise (closing a long)","Review dYdX take-profit trigger semantics (opposite direction of stop orders for the same side)"],"exampleFix":"// before\nvalidate_conditional_order(DydxOrderType::TakeProfitLimit, OrderSide::Buy, price_50k, trigger_55k)?;\n// after\nvalidate_conditional_order(DydxOrderType::TakeProfitLimit, OrderSide::Buy, price_50k, trigger_45k)?;","handlingStrategy":"validation","validationCode":"fn valid_tp_buy(price: f64, trigger: f64) -> bool { trigger <= price }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember take-profit triggers invert relative to stops for the same side","Add integration tests that submit each conditional order type/side combination with valid prices"],"tags":["rust","dydx","orders","validation"],"backgroundTag":"invalid-argument-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"}