nautechsystems/nautilus_trader · error · anyhow::Error
Unknown IB condition kind: {value}
Error message
Unknown IB condition kind: {value} What it means
IbConditionKind::from_str in crates/adapters/interactive_brokers/src/common/enums/order.rs:765 parses IB conditional-order kinds (price, time, margin, execution, volume, percent_change) and bails with anyhow if the lowercase input matches none of them.
Source
Thrown at crates/adapters/interactive_brokers/src/common/enums/order.rs:765
Self::Execution => "execution",
Self::Volume => "volume",
Self::PercentChange => "percent_change",
}
}
}
impl FromStr for IbConditionKind {
type Err = anyhow::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
match value.to_ascii_lowercase().as_str() {
"price" => Ok(Self::Price),
"time" => Ok(Self::Time),
"margin" => Ok(Self::Margin),
"execution" => Ok(Self::Execution),
"volume" => Ok(Self::Volume),
"percent_change" | "percentchange" => Ok(Self::PercentChange),
_ => anyhow::bail!("Unknown IB condition kind: {value}"),
}
}
}
impl Display for IbConditionKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
/// Interactive Brokers conditional order conjunction 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 one of: "price", "time", "margin", "execution", "volume", "percent_change" (case-insensitive; "percentchange" also accepted).
- Check spelling against the match arms; note "pct_change" is NOT accepted.
- Normalize via to_ascii_lowercase + trim before parsing.
- Add a new arm upstream if an IB condition kind is missing.
Example fix
// before let k = "pct_change".parse::<IbConditionKind>()?; // bail! // after let k = "percent_change".parse::<IbConditionKind>()?; // Ok(PercentChange)
Defensive patterns
Strategy: validation
Validate before calling
const IB_CONDITION_KINDS: &[&str] = &["price","time","margin","execution","volume","percent_change","percentchange"];
fn is_valid_condition_kind(s: &str) -> bool {
IB_CONDITION_KINDS.contains(&s.trim().to_ascii_lowercase().as_str())
} Type guard
fn as_condition_kind(s: &str) -> Option<IbConditionKind> {
s.trim().to_ascii_lowercase().parse::<IbConditionKind>().ok()
} Try / catch
match value.parse::<IbConditionKind>() {
Ok(kind) => add_condition(kind),
Err(e) => log::error!("unknown condition kind '{value}': {e}"),
} Prevention
- Use snake_case API codes, not TWS UI labels, for condition kinds.
- Lowercase and trim before parsing; spelling must match exactly (e.g. 'percent_change', not 'pct_change').
- Keep a constants list of valid kinds shared with config schemas.
When it happens
Trigger: Parsing a condition kind string like "Price", "PRICE", "pct_change", "percentage", or any other name not in the accepted list (input is lowercased before matching, so only spelling differences matter).
Common situations: Building IB conditional orders (e.g. price-triggered) with hand-written kind names; copying condition names from IB TWS UI text rather than the API codes; typos like "precent_change".
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 condition conjunction: {value}
- Unknown IB option right: {value}
- Unknown IB historical tick type: {value}
- Unknown IB action: {value}
- Unknown IB order status: {value}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/31d105361ff15abb.
Report an issue: GitHub.