{"record":{"id":"9c43455144a0a5b4","repo":"nautechsystems/nautilus_trader","slug":"stop-buy-trigger-price-trigger-price-must-be","errorCode":null,"errorMessage":"Stop buy trigger_price ({trigger_price}) must be >= limit price ({price})","messagePattern":"Stop 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":250,"sourceCode":"    order_type: DydxOrderType,\n    trigger_price: Option<Decimal>,\n    price: Decimal,\n    side: OrderSide,\n) -> anyhow::Result<()> {\n    if !order_type.is_conditional() {\n        return Ok(());\n    }\n\n    let trigger_price = trigger_price\n        .ok_or_else(|| anyhow::anyhow!(\"trigger_price required for {order_type:?}\"))?;\n\n    // Validate trigger price relative to limit price\n    match order_type {\n        DydxOrderType::StopLimit | DydxOrderType::StopMarket => {\n            // Stop orders: trigger when price falls (sell) or rises (buy)\n            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                    );","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/http/parse.rs#L232-L268","documentation":"For dYdX stop orders (StopLimit/StopMarket) on the buy side, the trigger price must be at or above the limit/order price — a buy stop triggers on upward movement. `validate_conditional_order` throws this error when `trigger_price < price` for a buy stop order.","triggerScenarios":"Calling `validate_conditional_order` (via order submission) with a StopLimit or StopMarket buy order whose trigger price is below the limit price, e.g. trigger 40_000 with limit price 50_000.","commonSituations":"Confusing stop-buy semantics with stop-sell semantics; building conditional orders with swapped price arguments; porting logic from venues with different stop conventions.","solutions":["Raise the trigger price so it is >= the limit price for buy stop orders","Swap the order side if a downward-triggering order was intended (use Sell)","Re-check the ordering of `price` and `trigger_price` arguments at the call site"],"exampleFix":"// before\nvalidate_conditional_order(DydxOrderType::StopLimit, OrderSide::Buy, price_50k, trigger_40k)?;\n// after\nvalidate_conditional_order(DydxOrderType::StopLimit, OrderSide::Buy, price_50k, trigger_55k)?;","handlingStrategy":"validation","validationCode":"fn valid_stop_buy(price: f64, trigger: f64) -> bool { trigger >= price }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unit-test conditional order builders for both sides with boundary trigger prices","Document trigger-direction rules for stop vs take-profit per side"],"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"}