nautechsystems/nautilus_trader · error · anyhow::Error

Stop sell trigger_price ({trigger_price}) must be <= limit p

Error message

Stop sell trigger_price ({trigger_price}) must be <= limit price ({price})

What it means

For dYdX stop orders (StopLimit/StopMarket) on the sell side, the trigger price must be at or below the limit/price — a sell stop triggers on downward movement. `validate_conditional_order` throws this error when `trigger_price > price` for a sell stop order.

Source

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

    if !order_type.is_conditional() {
        return Ok(());
    }

    let trigger_price = trigger_price
        .ok_or_else(|| anyhow::anyhow!("trigger_price required for {order_type:?}"))?;

    // Validate trigger price relative to limit price
    match order_type {
        DydxOrderType::StopLimit | DydxOrderType::StopMarket => {
            // Stop orders: trigger when price falls (sell) or rises (buy)
            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})"
                    );

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Lower the trigger price so it is <= the limit price for sell stop orders
  2. Swap the order side if an upward-triggering order was intended (use Buy)
  3. Verify price/trigger argument order at the call site

Example fix

// before
validate_conditional_order(DydxOrderType::StopLimit, OrderSide::Sell, price_50k, trigger_60k)?;
// after
validate_conditional_order(DydxOrderType::StopLimit, OrderSide::Sell, price_50k, trigger_45k)?;
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Calling `validate_conditional_order` via order submission with a StopLimit or StopMarket sell order whose trigger price is above the limit price, e.g. trigger 60_000 with price 50_000.

Common situations: Reusing buy-side stop parameters for a sell order; misreading trigger-vs-limit price semantics; automated strategies generating inverted stop levels.

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/d96e9d3a51ba92cf. Report an issue: GitHub.