{"record":{"id":"021480d9be38b7c9","repo":"nautechsystems/nautilus_trader","slug":"instrument-id-required-if-instrument-type-not-pr","errorCode":null,"errorMessage":"Instrument ID required if `instrument_type` not provided","messagePattern":"Instrument ID required if `instrument_type` not provided","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":4195,"sourceCode":"        {\n            return self\n                .request_spread_order_status_reports_scoped(\n                    account_id,\n                    instrument_id,\n                    start,\n                    end,\n                    open_only,\n                    limit,\n                    scope,\n                )\n                .await;\n        }\n\n        let instrument_type = if let Some(instrument_type) = instrument_type {\n            instrument_type\n        } else {\n            let instrument_id = instrument_id.ok_or_else(|| {\n                anyhow::anyhow!(\"Instrument ID required if `instrument_type` not provided\")\n            })?;\n            let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n            okx_instrument_type(&instrument)?\n        };\n\n        let mut history_base = GetOrderHistoryParamsBuilder::default();\n        history_base.inst_type(instrument_type);\n\n        if let Some(instrument_id) = instrument_id.as_ref() {\n            history_base.inst_id(instrument_id.symbol.inner().to_string());\n        }\n        let history_base = history_base.build().map_err(|e| anyhow::anyhow!(e))?;\n\n        let mut pending_base = GetOrderListParamsBuilder::default();\n        pending_base.inst_type(instrument_type);\n\n        if let Some(instrument_id) = instrument_id.as_ref() {\n            pending_base.inst_id(instrument_id.symbol.inner().to_string());","sourceCodeStart":4177,"sourceCodeEnd":4213,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L4177-L4213","documentation":"Order history requests to OKX require either an explicit instrument_type (inst_type) or an Instrument ID from which the adapter derives the instrument type via the cache. If neither is given, params cannot be built and anyhow::anyhow! is returned.","triggerScenarios":"Calling the order-history/report function with instrument_type=None and instrument_id=None; e.g. sweeping all order history without specifying instrument type.","commonSituations":"Bulk reconciliation scripts that omit both filters; callers assuming the adapter can infer instrument type without an instrument; stale cache making callers skip passing instrument_id.","solutions":["Provide instrument_id so the type is derived from the cached instrument","Provide instrument_type explicitly (e.g. SPOT, SWAP, FUTURES, OPTION)","Ensure the instrument cache is loaded before calling if relying on inference"],"exampleFix":"// before\nclient.get_order_history(None, None, start, end, ...).await?;\n// after\nclient.get_order_history(None, Some(instrument_id), start, end, ...).await?;","handlingStrategy":"validation","validationCode":"if instrument_type.is_none() && instrument_id.is_none() {\n    return Err(\"Provide either instrument_type or instrument_id for order history\".into());\n}","typeGuard":null,"tryCatchPattern":"match client.get_order_history(instrument_type, instrument_id, ...).await {\n    Err(e) if e.to_string().contains(\"Instrument ID required\") => {\n        // retry with an explicit instrument_type\n    }\n    other => other?,\n}","preventionTips":["Always pass instrument_id or instrument_type to OKX history queries","Load instruments into the cache before report requests","Default a fallback instrument_type in your config layer"],"tags":["okx","orders","missing-argument"],"backgroundTag":"missing-required-argument","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"}