nautechsystems/nautilus_trader · error · anyhow::Error

OUO contingency type not supported by BitMEX

Error message

OUO contingency type not supported by BitMEX

What it means

Generic guard in the TryFrom<ContingencyType> for BitmexContingencyType conversion: BitMEX has no exchange-side representation for the OUO (one-updates-the-other) contingency type, so any Nautilus order carrying ContingencyType::Ouo cannot be submitted to BitMEX.

Source

Thrown at crates/adapters/bitmex/src/common/enums.rs:408

    fn from(value: BitmexContingencyType) -> Self {
        match value {
            BitmexContingencyType::OneCancelsTheOther => Some(ContingencyType::Oco),
            BitmexContingencyType::OneTriggersTheOther => Some(ContingencyType::Oto),
            BitmexContingencyType::OneUpdatesTheOtherProportional
            | BitmexContingencyType::OneUpdatesTheOtherAbsolute => Some(ContingencyType::Ouo),
            BitmexContingencyType::Unknown => None,
        }
    }
}

impl TryFrom<ContingencyType> for BitmexContingencyType {
    type Error = anyhow::Error;

    fn try_from(value: ContingencyType) -> Result<Self, Self::Error> {
        match value {
            ContingencyType::Oco => Ok(Self::OneCancelsTheOther),
            ContingencyType::Oto => Ok(Self::OneTriggersTheOther),
            ContingencyType::Ouo => anyhow::bail!("OUO contingency type not supported by BitMEX"),
        }
    }
}

/// Represents the available peg price types on BitMEX.
#[derive(
    Copy,
    Clone,
    Debug,
    Display,
    PartialEq,
    Eq,
    AsRefStr,
    EnumIter,
    EnumString,
    Serialize,
    Deserialize,
)]

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use ContingencyType::Oco or ContingencyType::Oto for BitMEX contingent orders
  2. Implement OUO semantics manually (two linked orders with custom cancel/replace logic) outside the adapter
  3. Guard the strategy to refuse contingent orders on BitMEX unless type is OCO/OTO

Example fix

// before
let contingency = ContingencyType::Ouo;
// after
let contingency = ContingencyType::Oco; // or Oto, supported by BitMEX
Defensive patterns

Strategy: validation

Validate before calling

if order.contingency_type() == ContingencyType::Ouo && order.instrument_id().venue() == *BITMEX_VENUE {
    return Err("OUO unsupported on BitMEX; use Oco or Oto");
}

Prevention

When it happens

Trigger: Submitting or converting a contingent order whose ContingencyType is Ouo when translating to the BitMEX order representation.

Common situations: Strategies using OUO parent/child order relationships (supported on venues like Binance) are pointed at BitMEX without converting to OCO or OTO.

Related errors


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