nautechsystems/nautilus_trader · error · anyhow::Error
Unknown IB order type: {value}
Error message
Unknown IB order type: {value} What it means
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.
Source
Thrown at crates/adapters/interactive_brokers/src/common/enums/order.rs:423
"TRAIL LIMIT" => Ok(Self::TrailingStopLimit),
"MIT" => Ok(Self::MarketIfTouched),
"LIT" => Ok(Self::LimitIfTouched),
"MTL" => Ok(Self::MarketToLimit),
"MKT PRT" => Ok(Self::MarketWithProtection),
"STP PRT" => Ok(Self::StopWithProtection),
"MIDPRICE" => Ok(Self::Midprice),
"PEG MKT" => Ok(Self::PeggedToMarket),
"PEG STK" => Ok(Self::PeggedToStock),
"PEG MID" | "PEGMID" => Ok(Self::PeggedToMidpoint),
"PEG BENCH" | "PEGBENCH" => Ok(Self::PeggedToBenchmark),
"PEG BEST" | "PEGBEST" => Ok(Self::PegBest),
"REL" => Ok(Self::Relative),
"PASSV REL" => Ok(Self::PassiveRelative),
"VOL" => Ok(Self::Volatility),
"BOX TOP" => Ok(Self::BoxTop),
"REL + LMT" => Ok(Self::RelativeLimitCombo),
"REL + MKT" => Ok(Self::RelativeMarketCombo),
_ => anyhow::bail!("Unknown IB order type: {value}"),
}
}
}
impl Display for IbOrderType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
/// Interactive Brokers time-in-force values.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(
module = "nautilus_trader.adapters.interactive_brokers",
from_py_object,
rename_all = "SCREAMING_SNAKE_CASE"View on GitHub (pinned to 18893faf8b)
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.
Example fix
// before let t = "mkt".parse::<IbOrderType>()?; // bail! Unknown IB order type: mkt // after let t = "mkt".trim().to_ascii_uppercase().parse::<IbOrderType>()?; // Ok(Market)
Defensive patterns
Strategy: validation
Validate before calling
const IB_ORDER_TYPES: &[&str] = &["MKT","LMT","STP","STP LMT","REL","PASSV REL","VOL","BOX TOP","REL + LMT","REL + MKT"];
fn is_valid_ib_order_type(s: &str) -> bool {
IB_ORDER_TYPES.contains(&s.trim().to_ascii_uppercase().as_str())
} Type guard
fn as_ib_order_type(s: &str) -> Option<IbOrderType> {
s.trim().to_ascii_uppercase().parse::<IbOrderType>().ok()
} Try / catch
match value.parse::<IbOrderType>() {
Ok(t) => place_order(t),
Err(e) => log::error!("bad order type '{value}': {e}"), // inspect e for the offending value
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown IB option right: {value}
- Unknown IB historical tick type: {value}
- Unknown IB action: {value}
- Unknown IB order status: {value}
- Unknown IB time in force: {value}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/b77b10ee4b7703ba.
Report an issue: GitHub.