{"record":{"id":"d6f90919f182e462","repo":"nautechsystems/nautilus_trader","slug":"failed-to-resolve-instrument-id-for-contract","errorCode":null,"errorMessage":"Failed to resolve instrument ID for contract {}:{}:{}","messagePattern":"Failed to resolve instrument ID for contract (.+?):(.+?):(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/historical/client.rs","lineNumber":1090,"sourceCode":"            }\n            crate::config::SymbologyMethod::Raw => {\n                crate::common::parse::ib_contract_to_instrument_id_raw(contract, Some(venue)).ok()\n            }\n        };\n\n        if let Some(instrument_id) = parsed {\n            return Ok(instrument_id);\n        }\n\n        if let Ok(Some(instrument)) = self\n            .instrument_provider\n            .get_instrument(&self.ib_client, contract)\n            .await\n        {\n            return Ok(instrument.id());\n        }\n\n        anyhow::bail!(\n            \"Failed to resolve instrument ID for contract {}:{}:{}\",\n            contract.symbol,\n            contract.security_type,\n            contract.exchange\n        );\n    }\n}\n\nfn retreat_end_datetime(min_ts_nanos: u64) -> Option<Timestamp> {\n    let new_end_nanos = min_ts_nanos.saturating_sub(1_000_000); // 1ms\n    Timestamp::from_nanosecond(i128::from(new_end_nanos)).ok()\n}\n\nfn should_continue_backward_pagination(\n    current_end_date: Timestamp,\n    current_start_date: Timestamp,\n) -> bool {\n    current_end_date > current_start_date","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/historical/client.rs#L1072-L1108","documentation":"This error is raised by the Interactive Brokers adapter when resolving a Nautilus instrument ID from an IB contract fails during historical data requests. The adapter queried IB's matching contract details (via get_instrument) but got no match, so it cannot map the contract to a Nautilus instrument ID for bars or ticks requests.","triggerScenarios":"Calling request_bars or request_ticks with a contract whose symbol, security type, or exchange doesn't match any contract IB returns from reqMatchingSymbols / contract details lookup, or when IB returns no qualifying match.","commonSituations":"Typos or non-canonical symbols in config (e.g. missing exchange suffix), requesting expired or ill-defined contracts, using exchanges IB historical data doesn't recognize, or symbol ambiguity that yields no unique match.","solutions":["Verify the instrument symbol, security type, and exchange exactly match a contract IB recognizes (test with TWS symbol search).","Use a fully qualified Nautilus instrument ID (e.g. ES.CME) so resolution can short-circuit without an IB lookup.","Check IB Gateway/TWS connectivity and market data subscriptions for the exchange in question.","If the contract is valid but ambiguous, add/correct the exchange field to disambiguate."],"exampleFix":"// before: ambiguous contract\nlet contract = Contract { symbol: \"ES\".into(), ..Default::default() };\n// after: disambiguated contract\nlet contract = Contract {\n    symbol: \"ES\".into(),\n    security_type: SecurityType::Future,\n    exchange: \"CME\".into(),\n    ..Default::default()\n};","handlingStrategy":"validation","validationCode":"fn contract_is_resolvable(contract: &Contract) -> bool {\n    !contract.symbol.is_empty()\n        && contract.security_type != SecurityType::Unknown\n        && !contract.exchange.is_empty()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify symbol, security type, and exchange when constructing IB contracts","Prefer fully qualified Nautilus instrument IDs over raw symbols","Validate the instrument exists in TWS symbol search before configuring it"],"tags":["interactive-brokers","instrument-resolution","historical-data"],"backgroundTag":"entity-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}