{"record":{"id":"b77b10ee4b7703ba","repo":"nautechsystems/nautilus_trader","slug":"unknown-ib-order-type-value","errorCode":null,"errorMessage":"Unknown IB order type: {value}","messagePattern":"Unknown IB order type: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/common/enums/order.rs","lineNumber":423,"sourceCode":"            \"TRAIL LIMIT\" => Ok(Self::TrailingStopLimit),\n            \"MIT\" => Ok(Self::MarketIfTouched),\n            \"LIT\" => Ok(Self::LimitIfTouched),\n            \"MTL\" => Ok(Self::MarketToLimit),\n            \"MKT PRT\" => Ok(Self::MarketWithProtection),\n            \"STP PRT\" => Ok(Self::StopWithProtection),\n            \"MIDPRICE\" => Ok(Self::Midprice),\n            \"PEG MKT\" => Ok(Self::PeggedToMarket),\n            \"PEG STK\" => Ok(Self::PeggedToStock),\n            \"PEG MID\" | \"PEGMID\" => Ok(Self::PeggedToMidpoint),\n            \"PEG BENCH\" | \"PEGBENCH\" => Ok(Self::PeggedToBenchmark),\n            \"PEG BEST\" | \"PEGBEST\" => Ok(Self::PegBest),\n            \"REL\" => Ok(Self::Relative),\n            \"PASSV REL\" => Ok(Self::PassiveRelative),\n            \"VOL\" => Ok(Self::Volatility),\n            \"BOX TOP\" => Ok(Self::BoxTop),\n            \"REL + LMT\" => Ok(Self::RelativeLimitCombo),\n            \"REL + MKT\" => Ok(Self::RelativeMarketCombo),\n            _ => anyhow::bail!(\"Unknown IB order type: {value}\"),\n        }\n    }\n}\n\nimpl Display for IbOrderType {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.write_str(self.as_str())\n    }\n}\n\n/// Interactive Brokers time-in-force values.\n#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n#[cfg_attr(\n    feature = \"python\",\n    pyo3::pyclass(\n        module = \"nautilus_trader.adapters.interactive_brokers\",\n        from_py_object,\n        rename_all = \"SCREAMING_SNAKE_CASE\"","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/common/enums/order.rs#L405-L441","documentation":"IbOrderType::from_str in crates/adapters/interactive_brokers/src/common/enums/order.rs:423 fails to match the input string against any known IB order type code (e.g. MKT, LMT, STOP, REL, VOL) and aborts with anyhow::bail!. The adapter only accepts the exact IB wire-code strings listed in the match arms.","triggerScenarios":"Calling `\"...\".parse::<IbOrderType>()` or `IbOrderType::from_str(s)` with a string that is not one of the supported IB order type codes, including lowercase variants, trailing whitespace, or a nautilus order type not mapped in the match.","commonSituations":"Config files or order scripts using lowercase codes like \"mkt\" or \"lmt\"; brokers/exchange docs listing order types the adapter has not mapped; typos like \"STOPLIMIT\" instead of \"STOP LMT\"; data imported from a different broker's vocabulary.","solutions":["Use the exact uppercase IB code from the match arms, e.g. \"MKT\", \"LMT\", \"STOP\", \"STOP LMT\", \"REL\".","Trim and uppercase the input string before parsing.","Check the Display impl for IbOrderType to see valid round-trip values.","If a genuinely supported IB order type is missing, add a match arm upstream in the adapter."],"exampleFix":"// before\nlet t = \"mkt\".parse::<IbOrderType>()?; // bail! Unknown IB order type: mkt\n// after\nlet t = \"mkt\".trim().to_ascii_uppercase().parse::<IbOrderType>()?; // Ok(Market)","handlingStrategy":"validation","validationCode":"const IB_ORDER_TYPES: &[&str] = &[\"MKT\",\"LMT\",\"STP\",\"STP LMT\",\"REL\",\"PASSV REL\",\"VOL\",\"BOX TOP\",\"REL + LMT\",\"REL + MKT\"];\nfn is_valid_ib_order_type(s: &str) -> bool {\n    IB_ORDER_TYPES.contains(&s.trim().to_ascii_uppercase().as_str())\n}","typeGuard":"fn as_ib_order_type(s: &str) -> Option<IbOrderType> {\n    s.trim().to_ascii_uppercase().parse::<IbOrderType>().ok()\n}","tryCatchPattern":"match value.parse::<IbOrderType>() {\n    Ok(t) => place_order(t),\n    Err(e) => log::error!(\"bad order type '{value}': {e}\"), // inspect e for the offending value\n}","preventionTips":["Always uppercase and trim order-type strings from config before parsing.","Round-trip through Display in tests to confirm allowed values.","Validate order type at config-load time, not at order-submit time."],"tags":["rust","enum-parsing","interactive-brokers","order-type"],"backgroundTag":"invalid-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"}