nautechsystems/nautilus_trader · error · anyhow::Error
Invalid venue order ID
Error message
Invalid venue order ID: {e} What it means
When canceling an order by venue_order_id, the adapter parses the venue ID into the format Binance expects. If parsing fails and no client_order_id fallback exists, it cannot construct a valid cancel request and bails with the parse error. If a client_order_id is present it logs a warning and falls back to cancel-by-client-order-id instead.
Solutions
- Provide the client_order_id as well so the adapter can fall back to cancel-by-client-order-id
- Verify the venue_order_id came from this Binance Futures venue and is intact
- Check that the instrument_id matches the venue of the original order
- Re-query the order by client_order_id to obtain the correct venue_order_id
Example fix
// before client.cancel_order(instrument_id, None, Some(venue_order_id), None) // after client.cancel_order(instrument_id, Some(client_order_id), Some(venue_order_id), None) // fallback available
Defensive patterns
Strategy: fallback
Validate before calling
if let Some(vid) = venue_order_id { if BinanceOrderId::parse(vid).is_err() && client_order_id.is_none() { abort("need client_order_id fallback"); } } Try / catch
match client.cancel_order(instrument_id, client_order_id, venue_order_id, None) { Err(e) if e.to_string().contains("Invalid venue order ID") => cancel_by_client_order_id(), r => r } Prevention
- Always carry the client_order_id alongside venue_order_id
- Sanity-check venue IDs come from the same venue as the client
- Re-fetch venue IDs after adapter restarts
When it happens
Trigger: Calling cancel_order with only a venue_order_id that is malformed, empty, or from a different venue/symbol (e.g. a Spot ID used against Futures), so BinanceOrderId::from_str fails.
Common situations: Cross-venue ID confusion after migrating a strategy between Binance Spot and Futures; corrupted or truncated venue order IDs stored in local state.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Binance Futures custom data requires BINANCE venue…
- Binance Futures does not support
- Binance Futures does not support second-level kline…
- Binance Futures position request has unresolved instrument
- Binance Futures supports L1_MBP and L2_MBP order book…
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9b1bfd4f61e2a3ff.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/futures/http/client.rs:2475
client_order_id: Option<ClientOrderId>,
) -> anyhow::Result<VenueOrderId> {
anyhow::ensure!(
venue_order_id.is_some() || client_order_id.is_some(),
"Either venue_order_id or client_order_id must be provided"
);
let symbol = format_binance_symbol(&instrument_id);
let order_id = match venue_order_id {
Some(venue_order_id) => match venue_order_id.inner().parse::<i64>() {
Ok(order_id) => Some(order_id),
Err(e) if client_order_id.is_some() => {
log::warn!(
"Unable to parse venue_order_id {venue_order_id} for cancel, canceling by client_order_id: {e}"
);
None
}
Err(e) => anyhow::bail!("Invalid venue order ID: {e}"),
},
None => None,
};
let params = BinanceCancelOrderParams {
symbol,
order_id,
orig_client_order_id: client_order_id
.map(|id| encode_broker_id(&id, BINANCE_NAUTILUS_FUTURES_BROKER_ID)),
recv_window: None,
};
let order = self.inner.cancel_order(¶ms).await?;
Ok(VenueOrderId::new(order.order_id.to_string()))
}
/// Cancels an algo order (conditional order) via the Binance Algo Service.
///View on GitHub (pinned to 18893faf8b)