{"record":{"id":"af3411768994fe21","repo":"nautechsystems/nautilus_trader","slug":"pending-ord-type-algo-order-pagination-for-in","errorCode":null,"errorMessage":"Pending {ord_type:?} algo order pagination for {inst_type:?} did not establish complete coverage","messagePattern":"Pending (.+?) algo order pagination for (.+?) did not establish complete coverage","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":6767,"sourceCode":"            let mut params = params_builder\n                .build()\n                .map_err(|e| anyhow::anyhow!(format!(\"Failed to build algo order params: {e}\")))?;\n\n            if query_pending {\n                let remaining = limit.map(|l| (l as usize).saturating_sub(reports.len()));\n                let pending_sweep = match self\n                    .paginate_algo_pending(&params, remaining, require_complete_active_coverage)\n                    .await\n                {\n                    Ok(sweep) => sweep,\n                    Err(e) if require_complete_active_coverage => {\n                        return Err(OKXPendingAlgoOrderReportsError::new(e).into());\n                    }\n                    Err(e) => return Err(e),\n                };\n\n                if require_complete_active_coverage && !pending_sweep.complete {\n                    return Err(OKXPendingAlgoOrderReportsError::new(anyhow::anyhow!(\n                        \"Pending {ord_type:?} algo order pagination for {inst_type:?} did not establish complete coverage\"\n                    ))\n                    .into());\n                }\n                complete &= pending_sweep.complete;\n                let mut pending = pending_sweep.items;\n\n                if let Some(state) = state {\n                    pending.retain(|order| order.state == state);\n                }\n\n                let pending_reports_complete = match self\n                    .collect_algo_reports(\n                        account_id,\n                        &pending,\n                        require_complete_active_coverage,\n                        &mut instruments_cache,\n                        ts_init,","sourceCodeStart":6749,"sourceCodeEnd":6785,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L6749-L6785","documentation":"When require_complete_active_coverage is set, pending algo order pagination must sweep every page (pagination complete flag true). If OKX pagination ended early (e.g. hitting the limit or losing cursor continuity), the adapter raises this error rather than returning a possibly incomplete set of live algo orders.","triggerScenarios":"Calling the algo order reports sweep with require_complete_active_coverage=true while pending-sweep returns complete=false, typically when the limit cap truncates the pending pages or OKX paginates across more records than the allowance.","commonSituations":"Reconciliation of live algo orders with strict coverage on an account with many pending algo orders and a small limit; transient OKX pagination inconsistencies.","solutions":["Increase the limit / allow more pages so the sweep can finish","Retry the sweep; transient pagination gaps can resolve on retry","Set require_complete_active_coverage=false only if partial views are acceptable","Sweep per instrument_type to reduce result volume per pass"],"exampleFix":"// before\nreports(client, ord_type, inst_type, Some(100), /*require_complete*/ true)\n// after\nreports(client, ord_type, inst_type, None, true) // no artificial cap, allow full sweep","handlingStrategy":"retry","validationCode":"// pre-check: size the pending book against your limit allowance\nlet est = account_pending_algo_count();\nif require_complete && est > limit.unwrap_or(usize::MAX) {\n    return Err(\"limit too small for complete coverage\".into());\n}","typeGuard":null,"tryCatchPattern":"match client.algo_order_reports(...).await {\n    Err(e) if e.to_string().contains(\"did not establish complete coverage\") => {\n        backoff_retry(|| client.algo_order_reports(...), 3).await?\n    }\n    other => other?,\n}","preventionTips":["Avoid artificial small limits when require_complete_active_coverage=true","Retry sweeps before failing reconciliation","Only relax the completeness flag when partial data is explicitly acceptable"],"tags":["okx","algo-orders","pagination","reconciliation"],"backgroundTag":"unexpected-api-response-shape","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"}