nautechsystems/nautilus_trader · error · anyhow::Error

Pegged orders only supported for LIMIT order type, was {orde

Error message

Pegged orders only supported for LIMIT order type, was {order_type:?}

What it means

Parameter validation in BitmexHttpClient.submit_order: pegged-order parameters (peg price type or offset) were provided for a non-LIMIT order. BitMEX only supports pegging on limit orders, so the request is rejected.

Source

Thrown at crates/adapters/bitmex/src/http/client.rs:1726

            params.peg_price_type(BitmexPegPriceType::TrailingStopPeg);

            // BitMEX requires negative offset for stop-sell orders
            let signed_offset = match order_side {
                OrderSide::Sell => -offset.abs(),
                OrderSide::Buy => offset.abs(),
            };
            params.peg_offset_value(signed_offset);
        }

        // Pegged orders (BBO) via params override
        if peg_price_type.is_none() && peg_offset_value.is_some() {
            anyhow::bail!("`peg_offset_value` requires `peg_price_type`");
        }

        if let Some(peg_type) = peg_price_type {
            if order_type != OrderType::Limit {
                anyhow::bail!(
                    "Pegged orders only supported for LIMIT order type, was {order_type:?}"
                );
            }
            params.ord_type(BitmexOrderType::Pegged);
            params.peg_price_type(peg_type);

            if let Some(offset) = peg_offset_value {
                params.peg_offset_value(offset);
            }
        }

        let mut exec_inst = Vec::new();

        if post_only {
            exec_inst.push(BitmexExecInstruction::ParticipateDoNotInitiate);
        }

        if reduce_only {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use OrderType::Limit when peg_price_type is set
  2. Remove the peg_price_type for non-limit orders
  3. Guard the peg parameter block with an order-type check

Example fix

// before
ord_type(Market) + peg_price_type(LastPeg)
// after
ord_type(Limit) + peg_price_type(LastPeg)
Defensive patterns

Strategy: validation

Validate before calling

if peg_price_type.is_some() && order_type != OrderType::Limit {
    return Err(anyhow::anyhow!("pegged orders require OrderType::Limit"));
}

Prevention

When it happens

Trigger: Calling submit_order with peg_price_type=Some(...) while order_type is Market or another non-Limit type.

Common situations: Applying peg params in a shared submit path that handles market and limit orders; ordering a pegged-to-BBO order but building it as a market order.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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