{"record":{"id":"9b1e9d22e2ce05f7","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-stk-for-e","errorCode":null,"errorMessage":"Failed to parse `stk` '{}' for {}: {e}","messagePattern":"Failed to parse `stk` '(.+?)' for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/parse.rs","lineNumber":2502,"sourceCode":"    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 {\n        matches!(definition.ct_type, OKXContractType::Inverse)\n    };\n\n    let listing_time = definition\n        .list_time\n        .ok_or_else(|| anyhow::anyhow!(\"`list_time` is required for {}\", definition.inst_id))?;","sourceCodeStart":2484,"sourceCodeEnd":2520,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/parse.rs#L2484-L2520","documentation":"Thrown when the OKX `stk` (strike price) string fails to parse into a Nautilus `Price`. The strike is mandatory for options; an unparseable decimal value aborts construction, reporting the raw string and inst_id alongside the underlying Price parse error.","triggerScenarios":"`parse_option_instrument` via `parse_instrument_any` receives a definition whose `stk` is non-numeric, negative, empty-but-not-guarded, or exceeds Price precision bounds.","commonSituations":"Corrupt OKX responses or third-party data mirrors; fixtures with placeholder strike values; exponent-notation strikes rejected by Price::from_str.","solutions":["Inspect the raw `stk` value for the inst_id and fix the source data.","Normalize the strike to plain decimal notation before parsing.","Skip options with unusable strike values instead of failing the entire instrument load."],"exampleFix":"// before\nstk: \"52000.00$\"  // trailing unit breaks parse\n// after\nstk: \"52000.00\"","handlingStrategy":"validation","validationCode":"if definition.stk.parse::<f64>().map(|v| v <= 0.0).unwrap_or(true) {\n    eprintln!(\"skipping {}: bad strike {}\", definition.inst_id, definition.stk);\n    return Ok(None);\n}","typeGuard":"fn valid_strike(s: &str) -> bool {\n    s.parse::<f64>().map(|v| v.is_finite() && v > 0.0).unwrap_or(false)\n}","tryCatchPattern":"match Price::from_str(&definition.stk) {\n    Ok(p) => p,\n    Err(e) => return Err(anyhow!(\"bad strike for {}: {e}\", definition.inst_id)),\n}","preventionTips":["Validate strike is positive decimal before parsing.","Strip currency symbols/units from numeric strings.","Skip options with unusable strikes."],"tags":["okx","instrument-parsing","options","parse-error"],"backgroundTag":"invalid-argument-format","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"}