nautechsystems/nautilus_trader · error · anyhow::Error

missing positive trigger_price for Binance algo order type

Error message

missing positive trigger_price for Binance algo order type {:?}

What it means

When parsing a futures algo (conditional) order websocket update, parse_algo_trigger_price requires a positive trigger price for order types where requires_algo_trigger_price returns true (e.g. STOP_MARKET). A missing/non-positive trigger_price for such types aborts parsing.

Solutions

  1. Verify the order was placed with a valid stopPrice; re-fetch order state via REST if the stream record is incomplete.
  2. Extend requires_algo_trigger_price/parse logic if a newly added order type should not require a trigger price.
  3. Correct test/mock payloads to include a positive triggerPrice.

Example fix

// before
{"o": {"ot": "STOP_MARKET", "tp": "0"}}
// after
{"o": {"ot": "STOP_MARKET", "tp": "25000.00"}}
Defensive patterns

Strategy: validation

Validate before calling

fn needs_trigger(order_type: &str) -> bool {
    matches!(order_type, "STOP_MARKET" | "TAKE_PROFIT_MARKET")
}
if needs_trigger(ot) && tp.parse::<f64>().map(|v| v <= 0.0).unwrap_or(true) {
    return Err("algo update requires positive trigger price");
}

Try / catch

match result {
    Err(e) if e.to_string().contains("missing positive trigger_price") => {
        tracing::warn!("algo stream update lacks trigger price; reconcile via REST");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Receiving an algo order update event whose triggerPrice field is empty, "0", or negative while algo_data.order_type requires a trigger (e.g. STOP_MARKET, TAKE_PROFIT_MARKET).

Common situations: Cancelled or expired conditional orders reported with zeroed prices; new algo order types added by Binance that the requires_algo_trigger_price mapping treats as trigger-requiring but the payload omits; mock/test events missing triggerPrice.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs:449

    }

    Price::from_decimal_dp(decimal, precision)
        .map(Some)
        .map_err(|e| anyhow::anyhow!("invalid {field} precision: {e}"))
}

fn parse_algo_trigger_price(
    algo_data: &AlgoOrderUpdateData,
    price_precision: u8,
) -> anyhow::Result<Option<Price>> {
    let trigger_price = parse_positive_price_at_precision(
        &algo_data.trigger_price,
        price_precision,
        "trigger_price",
    )?;

    if trigger_price.is_none() && requires_algo_trigger_price(algo_data.order_type) {
        anyhow::bail!(
            "missing positive trigger_price for Binance algo order type {:?}",
            algo_data.order_type
        );
    }

    Ok(trigger_price)
}

fn parse_algo_limit_price(
    algo_data: &AlgoOrderUpdateData,
    price_precision: u8,
) -> anyhow::Result<Option<Price>> {
    let price = parse_positive_price_at_precision(&algo_data.price, price_precision, "price")?;

    if price.is_none() && requires_algo_limit_price(algo_data.order_type) {
        anyhow::bail!(
            "missing positive price for Binance algo order type {:?}",
            algo_data.order_type

View on GitHub (pinned to 18893faf8b)