{"record":{"id":"3bcc01becf22a966","repo":"nautechsystems/nautilus_trader","slug":"option-instruments-require-instrument-family-okx","errorCode":null,"errorMessage":"option instruments require instrument_family (OKX instFamily), for example BTC-USD","messagePattern":"option instruments require instrument_family \\(OKX instFamily\\), for example BTC-USD","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":2387,"sourceCode":"    /// Option requests require `instrument_family` (OKX `instFamily`), for example `BTC-USD`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if `instrument_type` is option and `instrument_family` is missing,\n    /// the HTTP request fails, or instrument parsing fails.\n    ///\n    /// # Returns\n    ///\n    /// A tuple containing:\n    /// - `Vec<InstrumentAny>`: The parsed instruments\n    /// - `Vec<(Ustr, u64)>`: Mappings of inst_id to inst_id_code for WebSocket order operations\n    pub async fn request_instruments(\n        &self,\n        instrument_type: OKXInstrumentType,\n        instrument_family: Option<String>,\n    ) -> anyhow::Result<(Vec<InstrumentAny>, Vec<(Ustr, u64)>)> {\n        if instrument_type == OKXInstrumentType::Option && instrument_family.is_none() {\n            anyhow::bail!(\n                \"option instruments require instrument_family (OKX instFamily), for example BTC-USD\"\n            );\n        }\n\n        let resp = if instrument_type == OKXInstrumentType::Events {\n            let series_ids = if let Some(series_id) = instrument_family.clone() {\n                vec![series_id]\n            } else {\n                self.inner\n                    .get_event_contract_series(GetEventContractSeriesParams::default())\n                    .await\n                    .map_err(|e| anyhow::anyhow!(e))?\n                    .into_iter()\n                    .map(|series| series.series_id)\n                    .collect()\n            };\n\n            let mut event_instruments = Vec::new();","sourceCodeStart":2369,"sourceCodeEnd":2405,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L2369-L2405","documentation":"OKX's instruments endpoint requires an instFamily parameter when requesting OPTION instruments. request_instruments enforces this up front: if instrument_type is Option and instrument_family is None, it bails before making the HTTP call. Other instrument types (SPOT, SWAP, FUTURES) do not require a family.","triggerScenarios":"Calling request_instruments(OKXInstrumentType::Option, None), e.g. from adapter configuration that loads instruments by type without specifying the family.","commonSituations":"Configuring an OKX data/execution client with instrument_type=OPTION but leaving instrument_family unset in the config; generic instrument-loading code that only sets family for some venues.","solutions":["Pass an instrument_family such as \"BTC-USD\" when requesting OPTION instruments","Set instrument_family in the OKX adapter config (e.g. OKX_INSTRUMENT_FAMILY or equivalent config field)","Only request options for the specific families your strategy trades, once per family"],"exampleFix":"// before\nclient.request_instruments(OKXInstrumentType::Option, None).await?;\n// after\nclient.request_instruments(OKXInstrumentType::Option, Some(\"BTC-USD\".to_string())).await?;","handlingStrategy":"validation","validationCode":"if instrument_type == OKXInstrumentType::Option && instrument_family.is_none() {\n    return Err(anyhow::anyhow!(\"OPTION requests need an instrument_family, e.g. BTC-USD\"));\n}","typeGuard":"fn options_family_provided(t: OKXInstrumentType, family: &Option<String>) -> bool {\n    t != OKXInstrumentType::Option || family.is_some()\n}","tryCatchPattern":"match client.request_instruments(OKXInstrumentType::Option, family).await {\n    Ok((instruments, mids)) => { /* use */ }\n    Err(e) => log::error!(\"instrument load failed: {e}\"),\n}","preventionTips":["Always configure instrument_family when instrument_type is OPTION","Load options one family at a time (BTC-USD, ETH-USD, ...)","Validate adapter config fields before constructing the client"],"tags":["okx","instruments","validation","options"],"backgroundTag":"missing-required-config-field","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"}