{"record":{"id":"221d1ae3e13daf22","repo":"nautechsystems/nautilus_trader","slug":"order-not-found","errorCode":null,"errorMessage":"Order not found","messagePattern":"Order not found","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/client.rs","lineNumber":2098,"sourceCode":"        if let Some(venue_order_id) = venue_order_id {\n            params.filter(serde_json::json!({\n                \"orderID\": venue_order_id.as_str()\n            }));\n        } else if let Some(client_order_id) = client_order_id {\n            params.filter(serde_json::json!({\n                \"clOrdID\": client_order_id.as_str()\n            }));\n        }\n\n        params.count(1i32);\n        let params = params.build().map_err(|e| anyhow::anyhow!(e))?;\n\n        let response = self.inner.get_orders(params).await?;\n\n        let order = response\n            .into_iter()\n            .next()\n            .ok_or_else(|| anyhow::anyhow!(\"Order not found\"))?;\n\n        let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let ts_init = self.generate_ts_init();\n\n        parse_order_status_report(&order, &instrument, &self.order_type_cache, ts_init)\n    }\n\n    /// Request multiple order status reports.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - Credentials are missing.\n    /// - The request fails.\n    /// - The API returns an error.\n    pub async fn request_order_status_reports(\n        &self,\n        instrument_id: Option<InstrumentId>,","sourceCodeStart":2080,"sourceCodeEnd":2116,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/client.rs#L2080-L2116","documentation":"request_order_status_report queried GET /api/v1/order with a filter on the order ID and got an empty response, so no order matched and there is nothing to convert into an OrderStatusReport. The adapter treats a missing order as a hard error for status reconciliation.","triggerScenarios":"Requesting the status of an order that never reached the venue (submit rejected), was already filled/cancelled and aged out of the default lookback window, uses a clOrdID from another environment, or where the API key lacks visibility (different account).","commonSituations":"Reconciliation after a restart querying orders older than BitMEX's default query window; testnet/mainnet key mismatch; querying an order placed before a counter reset so clOrdID collides/does not exist; the order still in-flight (submission latency) when queried immediately after submit.","solutions":["Widen the query window by adding a startTime filter, or query without count restrictions, if the order may have aged out.","Confirm the clOrdID exists on the venue via the BitMEX web UI or a direct REST query before treating it as missing.","Check API key/environment (testnet vs production) matches where the order was placed.","For reconciliation flows, treat not-found as a distinct condition (mark unknown/needs review) rather than retrying the identical query."],"exampleFix":"// before\nlet order = response.into_iter().next().ok_or_else(|| anyhow::anyhow!(\"Order not found\"))?;\n// after\nlet order = response.into_iter().next().ok_or_else(|| anyhow::anyhow!(\n    \"Order not found for client_order_id={client_order_id:?} on BitMEX (wrong env, aged out, or never accepted)\"\n))?;","handlingStrategy":"try-catch","validationCode":"// confirm the order was accepted at submit time and record the venue's echoed clOrdID\nlet submit_report = client.submit_order(...).await?;\nassert_eq!(submit_report.cl_ord_id, expected_cl_ord_id);","typeGuard":"fn order_maybe_missing(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"Order not found\")\n}","tryCatchPattern":"match client.request_order_status_report(instrument_id, Some(cl_id)).await {\n    Ok(report) => Ok(Some(report)),\n    Err(e) if order_maybe_missing(&e) => Ok(None), // reconcile as unknown, don't crash\n    Err(e) => Err(e),\n}","preventionTips":["Add a startTime filter to cover orders older than the default query window in reconciliation runs.","Confirm testnet vs mainnet API keys before querying order status.","Treat not-found as a reconciliation state, not necessarily a fatal error.","Allow a short grace period after submit before querying status (submission latency)."],"tags":["order-not-found","reconciliation","bitmex","http-client"],"backgroundTag":"record-not-found","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"}