{"record":{"id":"3285f64bff8f5063","repo":"nautechsystems/nautilus_trader","slug":"instrument-type-or-instrument-id-required-for-algo","errorCode":null,"errorMessage":"instrument_type or instrument_id required for algo order query","messagePattern":"instrument_type or instrument_id required for algo order query","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":6646,"sourceCode":"        end: Option<Timestamp>,\n        require_complete_active_coverage: bool,\n    ) -> anyhow::Result<AlgoOrderReportSweep> {\n        let mut instruments_cache: AHashMap<Ustr, InstrumentAny> = AHashMap::new();\n        let mut ambiguous_triggered_child_ids = AHashSet::new();\n        let has_specific_lookup = algo_id.is_some() || algo_client_order_id.is_some();\n        let start_ns = start.map(UnixNanos::from);\n        let end_ns = end.map(UnixNanos::from);\n        let mut complete = true;\n\n        let inst_type = if let Some(inst_type) = instrument_type {\n            inst_type\n        } else if let Some(inst_id) = instrument_id {\n            let instrument = self.instrument_from_cache(inst_id.symbol.inner())?;\n            let inst_type = okx_instrument_type(&instrument)?;\n            instruments_cache.insert(inst_id.symbol.inner(), instrument);\n            inst_type\n        } else {\n            anyhow::bail!(\"instrument_type or instrument_id required for algo order query\")\n        };\n\n        let ts_init = self.generate_ts_init();\n        let mut reports = Vec::new();\n        let mut seen: AHashMap<(String, String), usize> = AHashMap::new();\n\n        if has_specific_lookup {\n            let mut params_builder = GetAlgoOrderParamsBuilder::default();\n\n            if let Some(algo_id) = algo_id {\n                params_builder.algo_id(algo_id);\n            }\n\n            if let Some(client_order_id) = algo_client_order_id {\n                params_builder.algo_cl_ord_id(client_order_id.as_str().to_string());\n            }\n\n            let params = params_builder","sourceCodeStart":6628,"sourceCodeEnd":6664,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L6628-L6664","documentation":"The OKX HTTP adapter requires at least one filter to query algo orders: either the OKX `inst_type` (derived from a cached instrument when an `instrument_id` is given) or a `instrument_type` directly. When neither is supplied the request would be invalid per OKX's API, so the client bails before sending it.","triggerScenarios":"Calling the algo-order query/report generation with `instrument_type=None` and `instrument_id=None` (both `Option`s unset).","commonSituations":"Reconciliation or report generation code that passes only venue/optional filters (e.g. date range) without an instrument type or ID; generic query helpers that build requests from user input where instrument filters were omitted.","solutions":["Pass an `instrument_id` so the adapter can derive the instrument type from cache.","Explicitly pass an `instrument_type` (e.g. SWAP, FUT) to the algo order query.","If querying all algo orders, iterate over the instrument types you care about and issue one query per type."],"exampleFix":"// before\nlet reports = client.request_algo_order_reports(None, None, ...).await?;\n// after\nlet reports = client.request_algo_order_reports(Some(InstrumentId::from(\"BTC-USDT-SWAP.OKX\")), None, ...).await?;","handlingStrategy":"validation","validationCode":"if instrument_type.is_none() && instrument_id.is_none() {\n    return Err(anyhow::anyhow!(\"algo order query needs instrument_type or instrument_id\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an instrument_type or at least one instrument_id to algo order queries.","Validate query params at your call-site boundary before invoking the adapter.","Enumerate instrument types explicitly when you intend a broad query."],"tags":["okx","validation","parameters","algo-orders"],"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"}