{"record":{"id":"b67d29876dfdfa0f","repo":"nautechsystems/nautilus_trader","slug":"unsupported-opttype-kind-for-cannot-ma","errorCode":null,"errorMessage":"Unsupported `optType` '{kind:?}' for {}: cannot map to Nautilus OptionKind","messagePattern":"Unsupported `optType` '(.+?)' for (.+?): cannot map to Nautilus OptionKind","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/parse.rs","lineNumber":2496,"sourceCode":"    taker_fee: Option<Decimal>,\n    ts_init: UnixNanos,\n) -> anyhow::Result<InstrumentAny> {\n    validate_underlying(definition.inst_id, definition.uly)?;\n\n    let context = format!(\"OPTION instrument {}\", definition.inst_id);\n    let (underlying_str, quote_ccy_str) = definition.uly.split_once('-').ok_or_else(|| {\n        anyhow::anyhow!(\n            \"Invalid underlying '{}' for {}: expected format 'BASE-QUOTE'\",\n            definition.uly,\n            definition.inst_id\n        )\n    })?;\n\n    let instrument_id = parse_instrument_id(definition.inst_id);\n    let raw_symbol = Symbol::from_ustr_unchecked(definition.inst_id);\n    let underlying = Currency::get_or_create_crypto_with_context(underlying_str, Some(&context));\n    let option_kind: OptionKind = OptionKind::try_from(definition.opt_type).map_err(|kind| {\n        anyhow::anyhow!(\n            \"Unsupported `optType` '{kind:?}' for {}: cannot map to Nautilus OptionKind\",\n            definition.inst_id\n        )\n    })?;\n    let strike_price = Price::from_str(&definition.stk).map_err(|e| {\n        anyhow::anyhow!(\n            \"Failed to parse `stk` '{}' for {}: {e}\",\n            definition.stk,\n            definition.inst_id\n        )\n    })?;\n    let quote_currency = Currency::get_or_create_crypto_with_context(quote_ccy_str, Some(&context));\n    let settlement_currency =\n        Currency::get_or_create_crypto_with_context(definition.settle_ccy, Some(&context));\n\n    let is_inverse = if definition.ct_type == OKXContractType::None {\n        settlement_currency == underlying\n    } else {","sourceCodeStart":2478,"sourceCodeEnd":2514,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/parse.rs#L2478-L2514","documentation":"Thrown when the OKX `optType` value cannot be converted to a Nautilus `OptionKind`. Nautilus supports C (call) and P (put); any other value (empty string, or unexpected enumerations) has no mapping and aborts the parse naming the inst_id and raw kind.","triggerScenarios":"`parse_instrument_any`/`parse_option_instrument` gets an option definition whose `opt_type` is neither \"C\" nor \"P\" — e.g. empty string from a malformed response or a new OKX option type.","commonSituations":"OKX API responses missing `optType` for some option listings; new option product types introduced by OKX before adapter support; fixtures with default/empty opt_type values.","solutions":["Check the raw OKX response: `optType` should be \"C\" or \"P\"; skip records where it is not.","Set `opt_type` to a valid \"C\"/\"P\" value in test fixtures or manually built definitions.","If OKX introduced a new optType, extend the `TryFrom<...> for OptionKind` mapping in the adapter to support it."],"exampleFix":"// before\nopt_type: \"\"  // unmappable\n// after\nopt_type: \"C\"  // or \"P\"","handlingStrategy":"validation","validationCode":"if definition.opt_type != \"C\" && definition.opt_type != \"P\" {\n    eprintln!(\"skipping {}: unsupported optType {}\", definition.inst_id, definition.opt_type);\n    return Ok(None);\n}","typeGuard":"fn is_valid_opt_type(opt_type: &str) -> bool {\n    matches!(opt_type, \"C\" | \"P\")\n}","tryCatchPattern":"match OptionKind::try_from(definition.opt_type) {\n    Ok(kind) => kind,\n    Err(_) => return Err(anyhow!(\"unmapped optType for {}\", definition.inst_id)),\n}","preventionTips":["Only parse options whose optType is 'C' or 'P'.","Update the adapter's OptionKind mapping when OKX adds new types.","Keep fixtures using real optType values."],"tags":["okx","instrument-parsing","options","enum"],"backgroundTag":"invalid-enum-value","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"}