nautechsystems/nautilus_trader · error · anyhow::Error
Unsupported security type: {:?}
Error message
Unsupported security type: {:?} What it means
parse_ib_contract_to_instrument dispatches on the IB security type and only supports Future, Option, FuturesOption, Index, CFD, Commodity, and Bond. Any other security type (Stock, Forex, Crypto, BAG reaching here, or future API additions) is explicitly unsupported by this parser and fails with the type name in the message.
Source
Thrown at crates/adapters/interactive_brokers/src/providers/parse.rs:183
details: &ibapi::contracts::ContractDetails,
instrument_id: InstrumentId,
) -> anyhow::Result<InstrumentAny> {
let sec_type = &details.contract.security_type;
match sec_type {
SecurityType::Stock => Ok(parse_equity_contract(details, instrument_id)),
SecurityType::ForexPair => Ok(parse_forex_contract(details, instrument_id)),
SecurityType::Crypto => Ok(parse_crypto_contract(details, instrument_id)),
SecurityType::Future | SecurityType::ContinuousFuture => {
Ok(parse_futures_contract(details, instrument_id))
}
SecurityType::Option => parse_option_contract(details, instrument_id),
SecurityType::FuturesOption => parse_option_contract(details, instrument_id), // FOP uses same parsing as OPT
SecurityType::Index => Ok(parse_index_contract(details, instrument_id)),
SecurityType::CFD => Ok(parse_cfd_contract(details, instrument_id)),
SecurityType::Commodity => Ok(parse_commodity_contract(details, instrument_id)),
SecurityType::Bond => Ok(parse_bond_contract(details, instrument_id)),
_ => anyhow::bail!("Unsupported security type: {:?}", sec_type),
}
}
fn ib_contract_info(details: &ibapi::contracts::ContractDetails) -> nautilus_core::Params {
let mut info = nautilus_core::Params::new();
let mut contract = serde_json::Map::new();
let contract_params = contract_to_params(&details.contract);
for (key, value) in &contract_params {
contract.insert(key.clone(), value.clone());
}
info.insert("contract".to_string(), serde_json::Value::Object(contract));
info.insert(
"priceMagnifier".to_string(),
serde_json::Value::from(details.price_magnifier),
);
infoView on GitHub (pinned to 18893faf8b)
Solutions
- Route the contract to the correct adapter path (e.g. equity/forex handling) if one exists, instead of the instrument-details parser.
- Restrict configured instruments to supported security types (FUT, OPT, FOP, IND, CFD, COMMODITY, BOND).
- If you need the type supported, extend the match in parse_ib_contract_to_instrument with a new parser arm.
- Check your ibapi crate version for newly added SecurityType variants and update the match accordingly.
Example fix
// before: unsupported type reaches parser
// ContractDetails { security_type: SecurityType::Cash, .. } -> bail
// after: extend the dispatch
SecurityType::Forex => parse_forex_contract(details, instrument_id),
_ => anyhow::bail!("Unsupported security type: {:?}", sec_type), Defensive patterns
Strategy: validation
Validate before calling
fn security_type_supported(st: SecurityType) -> bool {
matches!(st, SecurityType::Future | SecurityType::Option
| SecurityType::FuturesOption | SecurityType::Index
| SecurityType::Cfd | SecurityType::Commodity | SecurityType::Bond)
} Prevention
- Filter configured instruments to supported security types before loading
- Check ibapi changelogs for new SecurityType variants after upgrades
- Handle unsupported types by skipping, not by pushing them through the parser
When it happens
Trigger: process_contract_detail or fetch_bag_contract receives ContractDetails whose security type falls into the parser's catch-all `_` arm — e.g. STK, CASH, CRYPTO, or an unfamiliar enum variant.
Common situations: Subscribing to instruments of an asset class the IB instrument provider doesn't model (e.g. spot FX or crypto through this parser), or an ibapi crate update introducing new SecurityType variants.
Related errors
- Empty expiry string
- Invalid expiry format: {}
- {e}
- Failed to parse execution timestamp '{time_str}': {e}
- Invalid `external_order_claims` instrument ID {claim}: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/cb9cf338477fa3cc.
Report an issue: GitHub.