nautechsystems/nautilus_trader · error · anyhow::Error
MarketToLimit order type is not supported by BitMEX
Error message
MarketToLimit order type is not supported by BitMEX
What it means
BitmexOrderType's TryFrom<OrderType> conversion rejects the Nautilus MarketToLimit order type because BitMEX has no equivalent order type. The conversion bails instead of silently mapping to something semantically different.
Source
Thrown at crates/adapters/bitmex/src/common/enums.rs:197
/// Pegged order, price automatically tracks market.
Pegged,
}
impl TryFrom<OrderType> for BitmexOrderType {
type Error = anyhow::Error;
fn try_from(value: OrderType) -> Result<Self, Self::Error> {
match value {
OrderType::Market => Ok(Self::Market),
OrderType::Limit => Ok(Self::Limit),
OrderType::StopMarket => Ok(Self::Stop),
OrderType::StopLimit => Ok(Self::StopLimit),
OrderType::MarketIfTouched => Ok(Self::MarketIfTouched),
OrderType::LimitIfTouched => Ok(Self::LimitIfTouched),
OrderType::TrailingStopMarket => Ok(Self::Pegged),
OrderType::TrailingStopLimit => Ok(Self::Pegged),
OrderType::MarketToLimit => {
anyhow::bail!("MarketToLimit order type is not supported by BitMEX")
}
}
}
}
impl BitmexOrderType {
/// Try to convert from Nautilus OrderType with anyhow::Result.
///
/// # Errors
///
/// Returns an error if the order type is MarketToLimit (not supported by BitMEX).
pub fn try_from_order_type(value: OrderType) -> anyhow::Result<Self> {
Self::try_from(value)
}
}
impl From<BitmexOrderType> for OrderType {
fn from(value: BitmexOrderType) -> Self {View on GitHub (pinned to 18893faf8b)
Solutions
- Use OrderType::Market or OrderType::Limit instead of MarketToLimit for BitMEX orders
- Add a validation/pre-check in the strategy that skips or rewrites MarketToLimit orders for the BitMEX venue
- Implement a custom adapter-level translation if MarketToLimit semantics are required
Example fix
// before let order = OrderFactory::market_to_limit(...); // bails on BitMEX // after let order = OrderFactory::limit(...); // BitMEX supports Limit/Market/Stop etc.
Defensive patterns
Strategy: validation
Validate before calling
if order.order_type() == OrderType::MarketToLimit && order.instrument_id().venue() == *BITMEX_VENUE {
return Err("MarketToLimit unsupported on BitMEX; use Market or Limit");
} Type guard
fn is_bitmex_supported_order_type(t: OrderType) -> bool {
!matches!(t, OrderType::MarketToLimit)
} Prevention
- Avoid venue-agnostic order-type defaults like MarketToLimit
- Add per-venue order-type whitelists in strategy config
- Test order construction against each target venue adapter
When it happens
Trigger: Submitting or converting any order whose OrderType is MarketToLimit when translating to a BitMEX order type via TryFrom.
Common situations: Users configure strategy defaults to MarketToLimit (common on other venues like Binance) and route orders to the BitMEX adapter without overriding the order type.
Related errors
- Unsupported order type for Betfair: {other:?}
- Unsupported order type for Binance Futures: {order_type:?}
- GTD time in force is not supported for BitMEX order submit;
- OUO contingency type not supported by BitMEX
- BitMEX does not support {}-{:?}-{:?} bars
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/b968e966e13a1667.
Report an issue: GitHub.