nautechsystems/nautilus_trader · error · anyhow::Error

Take profit buy trigger_price ({trigger_price}) must be <= l

Error message

Take profit buy trigger_price ({trigger_price}) must be <= limit price ({price})

What it means

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.

Source

Thrown at crates/adapters/dydx/src/http/parse.rs:266

            match side {
                OrderSide::Buy if trigger_price < price => {
                    anyhow::bail!(
                        "Stop buy trigger_price ({trigger_price}) must be >= limit price ({price})"
                    );
                }
                OrderSide::Sell if trigger_price > price => {
                    anyhow::bail!(
                        "Stop sell trigger_price ({trigger_price}) must be <= limit price ({price})"
                    );
                }
                _ => {}
            }
        }
        DydxOrderType::TakeProfitLimit | DydxOrderType::TakeProfitMarket => {
            // Take profit: trigger when price rises (sell) or falls (buy)
            match side {
                OrderSide::Buy if trigger_price > price => {
                    anyhow::bail!(
                        "Take profit buy trigger_price ({trigger_price}) must be <= limit price ({price})"
                    );
                }
                OrderSide::Sell if trigger_price < price => {
                    anyhow::bail!(
                        "Take profit sell trigger_price ({trigger_price}) must be >= limit price ({price})"
                    );
                }
                _ => {}
            }
        }
        _ => {}
    }

    Ok(())
}

/// Parses a dYdX perpetual market into a Nautilus [`InstrumentAny`].

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Lower the trigger price so it is <= the limit price for buy take-profit orders
  2. Use the sell side if the take-profit should trigger on a price rise (closing a long)
  3. Review dYdX take-profit trigger semantics (opposite direction of stop orders for the same side)

Example fix

// before
validate_conditional_order(DydxOrderType::TakeProfitLimit, OrderSide::Buy, price_50k, trigger_55k)?;
// after
validate_conditional_order(DydxOrderType::TakeProfitLimit, OrderSide::Buy, price_50k, trigger_45k)?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_tp_buy(price: f64, trigger: f64) -> bool { trigger <= price }

Prevention

When it happens

Trigger: Calling `validate_conditional_order` via order submission with a TakeProfitLimit or TakeProfitMarket buy order whose trigger price is above the limit price.

Common situations: Applying stop-order trigger intuition (trigger above for buy) to take-profit orders; generating take-profit levels with sign/side confusion in strategy code.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/fd226928c76c6c25. Report an issue: GitHub.