nautechsystems/nautilus_trader · error · anyhow::Error

missing positive price for Binance algo order type

Error message

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

What it means

parse_algo_limit_price requires a positive limit price for algo order types where requires_algo_limit_price is true (e.g. STOP, TAKE_PROFIT — limit-style conditional orders). If algo_data.price is missing, zero, or negative for such a type, parsing the update fails.

Solutions

  1. Ensure limit-style conditional orders carry a positive price field; refetch via REST if stream data is incomplete.
  2. Check that algo_data.order_type is correctly classified so market variants don't require a price.
  3. Fix test payloads to include a valid price.

Example fix

// before
{"o": {"ot": "STOP", "p": "0"}}
// after
{"o": {"ot": "STOP", "p": "24950.00"}}
Defensive patterns

Strategy: validation

Validate before calling

fn needs_limit_price(order_type: &str) -> bool {
    matches!(order_type, "STOP" | "TAKE_PROFIT")
}
if needs_limit_price(ot) && price.parse::<f64>().map(|v| v <= 0.0).unwrap_or(true) {
    return Err("limit-style algo update requires positive price");
}

Try / catch

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

Prevention

When it happens

Trigger: Receiving a futures algo update for a limit-style conditional order (e.g. STOP / TAKE_PROFIT) whose price field is empty or non-positive.

Common situations: Exchange reporting zeroed price on cancelled/expired algo orders; a payload for a market-style order type being misclassified as limit-style; test fixtures omitting price.

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

Appendix: source

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

    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
        );
    }

    Ok(price)
}

fn parse_trailing_offset_basis_points(raw: &str) -> Option<Decimal> {
    let rate = parse_required_decimal(raw, "callback_rate").ok()?;
    if rate <= Decimal::ZERO {
        return None;
    }

    rate.checked_mul(Decimal::from(100))
}

fn parse_working_type(working_type: BinanceWorkingType) -> TriggerType {

View on GitHub (pinned to 18893faf8b)