nautechsystems/nautilus_trader · error · anyhow::Error

Unknown IB builder time in force: {value}

Error message

Unknown IB builder time in force: {value}

What it means

IbBuilderTimeInForce::from_str in crates/adapters/interactive_brokers/src/common/enums/order.rs:639 (IB KittyBuilder/builder-futures TIF) fails when the string does not exactly match GTD, FOK, GTX, DTC, AUC, or OPG, and raises via anyhow::bail!. Note this enum's accepted set differs from the regular IbTimeInForce enum.

Source

Thrown at crates/adapters/interactive_brokers/src/common/enums/order.rs:639

        }
    }
}

impl FromStr for IbBuilderTimeInForce {
    type Err = anyhow::Error;

    fn from_str(value: &str) -> Result<Self, Self::Err> {
        match value {
            "DAY" => Ok(Self::Day),
            "GTC" => Ok(Self::GoodTillCancel),
            "IOC" => Ok(Self::ImmediateOrCancel),
            "GTD" => Ok(Self::GoodTillDate),
            "FOK" => Ok(Self::FillOrKill),
            "GTX" => Ok(Self::GoodTillCrossing),
            "DTC" => Ok(Self::DayTillCanceled),
            "AUC" => Ok(Self::Auction),
            "OPG" => Ok(Self::OpeningAuction),
            _ => anyhow::bail!("Unknown IB builder time in force: {value}"),
        }
    }
}

impl Display for IbBuilderTimeInForce {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

/// Interactive Brokers combo-leg open/close 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

  1. Use one of the builder-specific codes: "GTD", "FOK", "GTX", "DTC", "AUC", "OPG".
  2. If the value came from a regular IbTimeInForce, map it explicitly to the nearest builder variant instead of reusing the string.
  3. Normalize case/whitespace before parsing.
  4. Add a new match arm upstream if a builder TIF code is genuinely missing.

Example fix

// before
let tif = "DAY".parse::<IbBuilderTimeInForce>()?; // bail! Unknown IB builder time in force: DAY
// after
let tif = "GTD".parse::<IbBuilderTimeInForce>()?; // Ok(GoodTillDate)
Defensive patterns

Strategy: validation

Validate before calling

const IB_BUILDER_TIFS: &[&str] = &["GTD","FOK","GTX","DTC","AUC","OPG"];
fn is_valid_builder_tif(s: &str) -> bool {
    IB_BUILDER_TIFS.contains(&s.trim().to_ascii_uppercase().as_str())
}

Type guard

fn as_builder_tif(s: &str) -> Option<IbBuilderTimeInForce> {
    s.trim().to_ascii_uppercase().parse::<IbBuilderTimeInForce>().ok()
}

Try / catch

match value.parse::<IbBuilderTimeInForce>() {
    Ok(tif) => submit_builder_order(tif),
    Err(e) => log::error!("builder TIF '{value}' unsupported (builder != regular TIF set): {e}"),
}

Prevention

When it happens

Trigger: Parsing a builder order TIF such as "DAY", "GTC", or "IOC" — codes valid for regular orders but not for builder orders — or any mistyped/lowercase value.

Common situations: Reusing the regular-order TIF value in a builder-futures order payload; assuming both enums accept the same codes; config shared between regular and builder order paths.

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/46cce40e557761be. Report an issue: GitHub.