{"record":{"id":"d9a59c09a55efd53","repo":"nautechsystems/nautilus_trader","slug":"either-client-order-id-or-venue-order-id-must-be-p","errorCode":null,"errorMessage":"Either client_order_id or venue_order_id must be provided","messagePattern":"Either client_order_id or venue_order_id must be provided","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/client.rs","lineNumber":1812,"sourceCode":"    /// - Credentials are missing.\n    /// - The request fails.\n    /// - The order doesn't exist.\n    /// - The API returns an error.\n    pub async fn cancel_order(\n        &self,\n        instrument_id: InstrumentId,\n        client_order_id: Option<ClientOrderId>,\n        venue_order_id: Option<VenueOrderId>,\n    ) -> anyhow::Result<OrderStatusReport> {\n        let mut params = super::query::DeleteOrderParamsBuilder::default();\n        params.text(NAUTILUS_TRADER);\n\n        if let Some(venue_order_id) = venue_order_id {\n            params.order_id(vec![venue_order_id.as_str().to_string()]);\n        } else if let Some(client_order_id) = client_order_id {\n            params.cl_ord_id(vec![client_order_id.as_str().to_string()]);\n        } else {\n            anyhow::bail!(\"Either client_order_id or venue_order_id must be provided\");\n        }\n\n        let params = params.build().map_err(|e| anyhow::anyhow!(e))?;\n\n        let orders: Vec<BitmexOrder> = self.inner.cancel_orders_response(params).await?;\n        let order = orders\n            .into_iter()\n            .next()\n            .ok_or_else(|| anyhow::anyhow!(\"No order returned in cancel response\"))?;\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    /// Cancel multiple orders.\n    ///","sourceCodeStart":1794,"sourceCodeEnd":1830,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/client.rs#L1794-L1830","documentation":"cancel_order requires at least one order identifier. If neither client_order_id nor venue_order_id is supplied, the request cannot address any order on BitMEX, so the method bails before building the cancel request.","triggerScenarios":"Calling cancel_order with both identifier parameters None (or passing identifiers of an Option type that resolve to None at runtime).","commonSituations":"Cancel logic branching on order state where neither ID was captured; passing an untracked order that never received a venue_order_id and whose cl_ord_id was not stored.","solutions":["Pass the client_order_id for the order to cancel","Pass the venue_order_id if the client_order_id is unavailable","Ensure order identifiers are persisted/looked up before issuing the cancel"],"exampleFix":"// before\nclient.cancel_order(instrument_id, None, None).await?;\n// after\nclient.cancel_order(instrument_id, Some(client_order_id), None).await?;","handlingStrategy":"validation","validationCode":"if client_order_id.is_none() && venue_order_id.is_none() {\n    return Err(anyhow::anyhow!(\"cancel_order needs client_order_id or venue_order_id\"));\n}","typeGuard":null,"tryCatchPattern":"match client.cancel_order(instrument_id, client_order_id, venue_order_id).await {\n    Ok(o) => o,\n    Err(e) if e.to_string().contains(\"must be provided\") => {\n        log::error!(\"cancel skipped: no order identifier available\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Persist client_order_id for every submitted order","Only issue cancels for tracked orders","Prefer client_order_id (clOrdID) since it is known before venue acknowledgment"],"tags":["rust","bitmex","cancel-order","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-14T00:17:10.932Z"}