{"record":{"id":"c073b668176fb211","repo":"nautechsystems/nautilus_trader","slug":"unsupported-instrument-type","errorCode":null,"errorMessage":"unsupported instrument type","messagePattern":"unsupported instrument type","errorType":"exception","errorClass":"OKXInstrumentDefinitionError","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":2679,"sourceCode":"            let taker = if taker_str.is_empty() {\n                None\n            } else {\n                Decimal::from_str(taker_str).ok().map(|v| -v)\n            };\n\n            (maker, taker)\n        } else {\n            (None, None)\n        };\n\n        let ts_init = self.generate_ts_init();\n        let Some(instrument) =\n            parse_instrument_any(raw_inst, None, None, maker_fee, taker_fee, ts_init)\n                .map_err(|e| OKXInstrumentDefinitionError::new(symbol, e))?\n        else {\n            return Err(OKXInstrumentDefinitionError::new(\n                symbol,\n                anyhow::anyhow!(\"unsupported instrument type\"),\n            )\n            .into());\n        };\n\n        self.cache_instrument(instrument.clone());\n\n        Ok(instrument)\n    }\n\n    async fn request_spread_instrument(&self, symbol: &str) -> anyhow::Result<InstrumentAny> {\n        let resp = self\n            .inner\n            .get_spreads(GetSpreadsParams {\n                sprd_id: Some(symbol.to_string()),\n                ..Default::default()\n            })\n            .await\n            .map_err(|e| anyhow::anyhow!(e))?;","sourceCodeStart":2661,"sourceCodeEnd":2697,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L2661-L2697","documentation":"Raised when parse_instrument_any returns None for the instrument's raw OKX definition, i.e. the instrument's type/category is not one the adapter knows how to convert into a Nautilus instrument. The library wraps this in OKXInstrumentDefinitionError with the symbol so callers know which symbol failed and why.","triggerScenarios":"Requesting an instrument whose OKX inst_type/ct_type combination falls outside the adapter's supported set (e.g. an exotic or newly introduced OKX product category added upstream before the adapter supports it).","commonSituations":"OKX introduces a new instrument category and the adapter has not been updated; requesting instruments from an endpoint section the adapter does not model; mixing SPOT/MARGIN types unexpectedly into the parser.","solutions":["Check the adapter's parse_instrument_any to confirm which instrument types are supported and restrict requests to those.","Upgrade the nautilus OKX adapter to a version supporting the new instrument category.","Skip unsupported symbols when enumerating instruments instead of failing the whole load.","File/track an adapter update if OKX added a genuinely new product type."],"exampleFix":"// before\nlet inst = client.request_instrument(symbol)?;\n// after\nlet inst = match client.request_instrument(symbol) {\n    Ok(i) => i,\n    Err(e) if e.to_string().contains(\"unsupported instrument type\") => {\n        log::warn!(\"skipping unsupported instrument {symbol}\");\n        return Ok(None);\n    }\n    Err(e) => return Err(e.into()),\n};","handlingStrategy":"type-guard","validationCode":"// Check the adapter's supported types before requesting\nconst SUPPORTED: &[OKXInstrumentType] = &[Spot, Margin, Swap, Futures, Option];\nfn is_supported(t: OKXInstrumentType) -> bool { SUPPORTED.contains(&t) }","typeGuard":"fn is_instrument_any_supported(raw: &OKXInstrument) -> bool {\n    parse_instrument_any(raw, None, None, None, None, 0).is_some()\n}","tryCatchPattern":"match client.request_instrument(symbol).await {\n    Ok(i) => Ok(Some(i)),\n    Err(e) if e.to_string().contains(\"unsupported instrument type\") => {\n        log::warn!(\"skipping {symbol}: unsupported type\");\n        Ok(None)\n    }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Restrict instrument enumeration to inst_types the adapter supports.","Keep the OKX adapter updated when OKX adds new product categories.","Skip-and-log unsupported symbols in bulk loaders rather than aborting.","When a new OKX category appears, extend parse_instrument_any rather than working around it."],"tags":["okx","instrument-parsing","unsupported-type","instrument-definition"],"backgroundTag":"unsupported-enum-value","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"}