nautechsystems/nautilus_trader · error · anyhow::Error

`TrailingOffsetType` {:?} is not supported

Error message

`TrailingOffsetType` {:?} is not supported

What it means

IB trailing-stop orders support only price and percentage trailing offsets (plus basis points mapped to percentage). Any other TrailingOffsetType enum value on a trailing order cannot be mapped to IB fields (trailing_percent / aux_price), so apply_trailing_order_policy bails.

Source

Thrown at crates/adapters/interactive_brokers/src/execution/transform/policy.rs:87

        order.order_type(),
        NautilusOrderType::TrailingStopMarket | NautilusOrderType::TrailingStopLimit
    ) {
        return Ok(());
    }

    if let Some(trailing_offset) = order.trailing_offset() {
        let trailing_offset_f64 = trailing_offset.to_string().parse::<f64>().map_err(|e| {
            anyhow::anyhow!("Failed to convert trailing offset {trailing_offset} to f64: {e}")
        })?;

        match order.trailing_offset_type() {
            Some(TrailingOffsetType::BasisPoints) => {
                ib_order.trailing_percent = Some(trailing_offset_f64 / 100.0);
            }
            Some(TrailingOffsetType::Price) | None => {
                ib_order.aux_price = Some(trailing_offset_f64);
            }
            Some(other) => anyhow::bail!("`TrailingOffsetType` {:?} is not supported", other),
        }
    }

    if let Some(trigger_price) = order.trigger_price() {
        let converted_trigger = convert_price(trigger_price, price_magnifier);
        ib_order.trail_stop_price = Some(converted_trigger);
        ib_order.trigger_method = order
            .trigger_type()
            .map(trigger_type_to_ib_trigger_method)
            .unwrap_or_default();
    }

    Ok(())
}

pub(super) fn apply_display_quantity_policy(ib_order: &mut IBOrder, order: &OrderAny) {
    if let Some(display_qty) = order.display_qty() {
        ib_order.display_size = Some(display_qty.as_f64() as i32);

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the order's trailing_offset_type to TrailingOffsetType::Price (absolute price offset) or BasisPoints
  2. Convert the tick-based offset to an absolute price offset before creating the order: offset_ticks * instrument.price_increment
  3. Route trailing-stop orders to a venue that supports tick-based trailing offsets instead of IB

Example fix

// before
order_factory.trailing_stop_market(side, qty, TrailingOffsetType::Ticks, ...)
// after
order_factory.trailing_stop_market(side, qty, TrailingOffsetType::Price, ...) // offset in price units
Defensive patterns

Strategy: validation

Validate before calling

match order.trailing_offset_type() {
    None | Some(TrailingOffsetType::Price) | Some(TrailingOffsetType::BasisPoints) => {},
    Some(other) => return Err(anyhow::anyhow!("IBKR does not support trailing offset type {:?}", other)),
}

Type guard

fn ibkr_supported_trailing_offset(t: TrailingOffsetType) -> bool {
    matches!(t, TrailingOffsetType::Price | TrailingOffsetType::BasisPoints)
}

Prevention

When it happens

Trigger: nautilus_order_to_ib_order -> apply_trailing_order_policy with an order having a trailing offset type other than Price, BasisPoints, or None (e.g. TrailingOffsetType::Ticks or BasisPointsPerSecond depending on enum variants), typically on TRAILING_STOP_MARKET orders.

Common situations: Strategies configured with tick-based trailing stops (common on crypto/futures venues) submitted to IB, where IB's API has no equivalent field.

Related errors


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