{"record":{"id":"bed14d845c7b2898","repo":"nautechsystems/nautilus_trader","slug":"no-usable-instruments-for-instrument-type-can","errorCode":null,"errorMessage":"No usable instruments for {instrument_type:?}, cannot initialize execution client","messagePattern":"No usable instruments for (.+?), cannot initialize execution client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":1349,"sourceCode":"\n            for instrument_type in &instrument_types {\n                let Some(families) =\n                    resolve_instrument_families(&self.config.instrument_families, *instrument_type)\n                else {\n                    continue;\n                };\n\n                if families.is_empty() {\n                    let (instruments, inst_id_codes) = self\n                        .http_client\n                        .request_instruments(*instrument_type, None)\n                        .await\n                        .with_context(|| {\n                            format!(\"failed to request OKX instruments for {instrument_type:?}\")\n                        })?;\n\n                    if instruments.is_empty() {\n                        anyhow::bail!(\n                            \"No usable instruments for {instrument_type:?}, \\\n                             cannot initialize execution client\"\n                        );\n                    }\n\n                    log::debug!(\n                        \"Loaded {} {instrument_type:?} instruments\",\n                        instruments.len()\n                    );\n\n                    self.http_client.cache_instruments(&instruments);\n                    all_instruments.extend(instruments);\n                    all_inst_id_codes.extend(inst_id_codes);\n                } else {\n                    for family in &families {\n                        let (instruments, inst_id_codes) = self\n                            .http_client\n                            .request_instruments(*instrument_type, Some(family.clone()))","sourceCodeStart":1331,"sourceCodeEnd":1367,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L1331-L1367","documentation":"During `establish_session`, the execution client fetches OKX instrument definitions for each configured instrument type. If the HTTP instruments response for a type comes back empty, there is nothing to trade on, so the client refuses to initialize. Empty results usually mean the configured instrument type has no listings for the account/venue or the request silently returned nothing.","triggerScenarios":"`connect` -> `establish_session` calls the OKX instruments endpoint for a configured `instrument_type` (SPOT/FUTURES/SWAP/OPTION) and the returned list is empty — e.g. requesting OPTION without an underlying configured when none resolves, or an unsupported/unavailable type.","commonSituations":"Configuring OPTION instruments without setting the required `underlyings`/family config so the plain-type request returns nothing; querying a product type unavailable on the account's region; transient OKX API issue returning an empty payload that is not treated as an HTTP failure.","solutions":["Fix the instrument-types configuration to include only types that actually list instruments (e.g. SWAP, FUTURES, SPOT).","For options, configure the required underlyings/families so the correct instruments request is made.","Hit the OKX `/api/v5/public/instruments?instType=...` endpoint manually to confirm data is returned for your parameters.","Retry on transient API failures; the contextual error 'failed to request OKX instruments for {type}' above this one may carry the root cause."],"exampleFix":"// before\ninstrument_types = [\"OPTION\"]  # no underlyings configured -> empty response\n// after\ninstrument_types = [\"SWAP\", \"OPTION\"]\nunderlyings = [\"BTC-USD\", \"ETH-USD\"]  # required for OPTION requests","handlingStrategy":"validation","validationCode":"// verify instruments exist for the configured type before connecting\nlet resp = reqwest::get(\"https://www.okx.com/api/v5/public/instruments?instType=SWAP\")\n    .await?.json::<serde_json::Value>().await?;\nif resp[\"data\"].as_array().map_or(true, |a| a.is_empty()) {\n    return Err(anyhow::anyhow!(\"OKX returned no SWAP instruments; fix config\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure only OKX product types with active listings (SPOT/SWAP/FUTURES/OPTION).","For options, always configure underlyings/families so the correct request is made.","Smoke-test the instruments endpoint with your exact parameters before connecting."],"tags":["okx","instruments","initialization","empty-response"],"backgroundTag":"empty-result-set","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"}