{"record":{"id":"1825aee524be4a86","repo":"nautechsystems/nautilus_trader","slug":"no-valid-contracts-found-after-conversion","errorCode":null,"errorMessage":"No valid contracts found after conversion","messagePattern":"No valid contracts found after conversion","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/historical/client.rs","lineNumber":314,"sourceCode":"            if let Some(instrument_id) = self\n                .instrument_provider\n                .get_instrument_id_by_contract_id(contract.contract_id)\n                && self.instrument_provider.find(&instrument_id).is_none()\n                && let Err(e) = self\n                    .instrument_provider\n                    .fetch_contract_details(&self.ib_client, instrument_id, false, None)\n                    .await\n            {\n                tracing::warn!(\n                    \"Failed to auto-fetch contract details for contract ID {}: {}\",\n                    contract.contract_id,\n                    e\n                );\n            }\n        }\n\n        if all_contracts.is_empty() {\n            anyhow::bail!(\"No valid contracts found after conversion\");\n        }\n\n        let trading_hours = if use_rth {\n            TradingHours::Regular\n        } else {\n            TradingHours::Extended\n        };\n\n        let mut all_bars = Vec::new();\n\n        for contract in all_contracts {\n            for bar_spec_str in &bar_specifications {\n                // Parse bar spec (e.g., \"1-HOUR-LAST\")\n                let parts: Vec<&str> = bar_spec_str.split('-').collect();\n                if parts.len() != 3 {\n                    anyhow::bail!(\"Invalid bar specification format: {}\", bar_spec_str);\n                }\n","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/historical/client.rs#L296-L332","documentation":"After converting each provided InstrumentId to an IB Contract via the instrument provider, request_bars checks that at least one conversion succeeded. If every instrument_id failed to resolve (failures are only logged as warnings per id), the client bails because there is nothing to request.","triggerScenarios":"Calling request_bars with only instrument_ids where every id fails resolve_contract_for_instrument_async — e.g. ids not loadable/fetchable from the IB instrument provider (unknown symbol, wrong venue, provider not initialized, disconnected gateway).","commonSituations":"Typo'd or malformed instrument ids; using instruments never registered with the IB adapter; IB Gateway not logged in (market data farms disconnect); requesting futures options or exotic symbols the provider cannot map.","solutions":["Check the per-id warnings logged before this error to see which ids failed and why.","Pre-load instruments via the instrument provider (load_ids_with_return_async / fetch_contract_details) before requesting bars.","Verify the InstrumentId format and symbol match what IB expects (venue suffix, expiry in the id for futures).","Pass explicit Contract objects instead of instrument_ids if the provider cannot map them."],"exampleFix":"// before\nclient.request_bars(&[\"1-DAY-LAST\"], end, None, Some(\"1 M\"), None, Some(vec![bad_id]), true, 60).await?;\n// after\nprovider.load_ids_with_return_async(&ib_client, vec![id], None).await?;\nclient.request_bars(&[\"1-DAY-LAST\"], end, None, Some(\"1 M\"), None, Some(vec![id]), true, 60).await?;","handlingStrategy":"try-catch","validationCode":"for id in &ids {\n    provider.find(id).or_else(|| provider.fetch_contract_details(...))\n        .unwrap_or_else(|| panic!(\"cannot resolve {id} to IB contract\"));\n}","typeGuard":null,"tryCatchPattern":"match client.request_bars(...).await {\n    Ok(bars) => bars,\n    Err(e) if e.to_string().contains(\"No valid contracts found\") => {\n        eprintln!(\"check instrument ids/provider state: {e}\");\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Read the per-id warning logs emitted before this error.","Pre-load instruments via load_ids_with_return_async before historical requests.","Verify IB Gateway/TWS connectivity and market data login."],"tags":["instrument-resolution","rust","historical-data","empty-result"],"backgroundTag":"resource-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}