{"record":{"id":"b968e966e13a1667","repo":"nautechsystems/nautilus_trader","slug":"markettolimit-order-type-is-not-supported-by-bitme","errorCode":null,"errorMessage":"MarketToLimit order type is not supported by BitMEX","messagePattern":"MarketToLimit order type is not supported by BitMEX","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/common/enums.rs","lineNumber":197,"sourceCode":"    /// Pegged order, price automatically tracks market.\n    Pegged,\n}\n\nimpl TryFrom<OrderType> for BitmexOrderType {\n    type Error = anyhow::Error;\n\n    fn try_from(value: OrderType) -> Result<Self, Self::Error> {\n        match value {\n            OrderType::Market => Ok(Self::Market),\n            OrderType::Limit => Ok(Self::Limit),\n            OrderType::StopMarket => Ok(Self::Stop),\n            OrderType::StopLimit => Ok(Self::StopLimit),\n            OrderType::MarketIfTouched => Ok(Self::MarketIfTouched),\n            OrderType::LimitIfTouched => Ok(Self::LimitIfTouched),\n            OrderType::TrailingStopMarket => Ok(Self::Pegged),\n            OrderType::TrailingStopLimit => Ok(Self::Pegged),\n            OrderType::MarketToLimit => {\n                anyhow::bail!(\"MarketToLimit order type is not supported by BitMEX\")\n            }\n        }\n    }\n}\n\nimpl BitmexOrderType {\n    /// Try to convert from Nautilus OrderType with anyhow::Result.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the order type is MarketToLimit (not supported by BitMEX).\n    pub fn try_from_order_type(value: OrderType) -> anyhow::Result<Self> {\n        Self::try_from(value)\n    }\n}\n\nimpl From<BitmexOrderType> for OrderType {\n    fn from(value: BitmexOrderType) -> Self {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/common/enums.rs#L179-L215","documentation":"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.","triggerScenarios":"Submitting or converting any order whose OrderType is MarketToLimit when translating to a BitMEX order type via TryFrom.","commonSituations":"Users configure strategy defaults to MarketToLimit (common on other venues like Binance) and route orders to the BitMEX adapter without overriding the order type.","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"],"exampleFix":"// before\nlet order = OrderFactory::market_to_limit(...); // bails on BitMEX\n// after\nlet order = OrderFactory::limit(...); // BitMEX supports Limit/Market/Stop etc.","handlingStrategy":"validation","validationCode":"if order.order_type() == OrderType::MarketToLimit && order.instrument_id().venue() == *BITMEX_VENUE {\n    return Err(\"MarketToLimit unsupported on BitMEX; use Market or Limit\");\n}","typeGuard":"fn is_bitmex_supported_order_type(t: OrderType) -> bool {\n    !matches!(t, OrderType::MarketToLimit)\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["bitmex","order-type","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}