nautechsystems/nautilus_trader · error · anyhow::Error

Unknown IB historical tick type: {value}

Error message

Unknown IB historical tick type: {value}

What it means

IbHistoricalTickType::from_str parses a historical data request's bar-what-to-show/tick type into the adapter enum, which currently only accepts "TRADES" and "BID_ASK" (case-insensitive). Any other string bails. It ensures the adapter only receives historical data kinds it can convert into Nautilus data types.

Source

Thrown at crates/adapters/interactive_brokers/src/common/enums/market_data.rs:59

impl IbHistoricalTickType {
    /// Returns the IB wire string.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Trades => "TRADES",
            Self::BidAsk => "BID_ASK",
        }
    }
}

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

    fn from_str(value: &str) -> Result<Self, Self::Err> {
        match value.to_ascii_uppercase().as_str() {
            "TRADES" => Ok(Self::Trades),
            "BID_ASK" => Ok(Self::BidAsk),
            _ => anyhow::bail!("Unknown IB historical tick type: {value}"),
        }
    }
}

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

/// Interactive Brokers trading hours selector.
#[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 supported values: "TRADES" or "BID_ASK" (case-insensitive) in your request/config.
  2. Check the adapter's supported list in crates/adapters/interactive_brokers/src/common/enums/market_data.rs and, if you need e.g. MIDPOINT, add a variant plus conversion mapping.
  3. For BID/ASK/MIDPOINT history, either switch to BID_ASK or file/prepare an adapter extension.

Example fix

// before
let tick_type: IbHistoricalTickType = "MIDPOINT".parse()?; // not supported
// after
let tick_type: IbHistoricalTickType = "BID_ASK".parse()?; // supported value
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_HIST_TICK_TYPES: &[&str] = &["TRADES", "BID_ASK"];
fn is_supported_hist_tick_type(v: &str) -> bool { SUPPORTED_HIST_TICK_TYPES.contains(&v.to_ascii_uppercase().as_str()) }

Type guard

fn as_ib_hist_tick_type(v: &str) -> Option<IbHistoricalTickType> {
    use std::str::FromStr;
    IbHistoricalTickType::from_str(v).ok()
}

Try / catch

match what_to_show.parse::<IbHistoricalTickType>() {
    Ok(t) => request_history(t),
    Err(e) => return Err(anyhow::anyhow!("unsupported whatToShow: {e}; use TRADES or BID_ASK")),
}

Prevention

When it happens

Trigger: Requesting IB historical data with whatToShow values like "BID", "ASK", "MIDPOINT", "ADJUSTED_LAST", "OPTION_IMPLIED_VOLATILITY", etc., then converting via IbHistoricalTickType::from_str/parse; passing lowercase variants is fine, but any unsupported keyword bails.

Common situations: Configuring a historical data request/market data subscription in a Nautilus config with a whatToShow string valid on the IB API but not yet supported by the adapter; switching between adapters and reusing another adapter's enum values; typos such as "TRADE" instead of "TRADES".

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/145aded75fb33fd9. Report an issue: GitHub.