nautechsystems/nautilus_trader · error
failed to parse venue_order_id
Error message
failed to parse venue_order_id: {e} What it means
query_order optionally converts the command's venue_order_id (a VenueOrderId wrapping a string) into the i64 Binance orderId. If the inner string is not a valid i64, the parse error is surfaced with this message.
Solutions
- Verify the order originated on Binance Futures and that venue_order_id holds Binance's numeric orderId.
- Query by client_order_id instead (the adapter builds orig_client_order_id automatically).
- Fix state/store corruption so venue_order_id contains the numeric exchange ID string.
- Add a pre-check that venue_order_id.inner().parse::<i64>().is_ok() before issuing the command.
Example fix
// before
if !command.venue_order_id.map(|id| id.inner().parse::<i64>().is_ok()).unwrap_or(true) {
return Err(...);
}
// after (caller-side guard)
let id_ok = command.venue_order_id
.map(|id| id.inner().parse::<i64>().is_ok())
.unwrap_or(true);
anyhow::ensure!(id_ok, "venue_order_id must be a numeric Binance orderId"); Defensive patterns
Strategy: type-guard
Validate before calling
fn is_numeric_venue_order_id(cmd: &QueryOrder) -> bool {
cmd.venue_order_id.map(|id| id.inner().parse::<i64>().is_ok()).unwrap_or(true)
} Type guard
fn valid_binance_order_id(id: &VenueOrderId) -> Option<i64> {
id.inner().parse::<i64>().ok()
} Try / catch
match client.query_order(cmd).await {
Err(e) if e.to_string().starts_with("failed to parse venue_order_id") => {
warn!("non-Binance or corrupted venue_order_id: {e}");
}
other => other?,
} Prevention
- Only route order-query commands to the venue that filled the order.
- Validate venue_order_id is numeric before persistence.
- Prefer client_order_id queries for adapter-placed orders.
When it happens
Trigger: Calling query_order with an order status command whose venue_order_id.inner() is not a plain numeric string — e.g. a UUID-style ID, an empty string, or an ID assigned by a different venue.
Common situations: Routing an order-query command to the Binance Futures execution client for an order that was actually placed on another venue; corrupted venue_order_id in persisted state; or a client_order_id accidentally stored as the venue_order_id.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Binance timestamp is outside the UnixNanos range
- Cannot extract condition_id from symbol
- Cannot extract token_id from symbol
- failed to build order query params
- Failed to parse =
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/d9564d7fe6c935cf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/futures/execution.rs:2876
}
fn query_order(&self, cmd: QueryOrder) -> anyhow::Result<()> {
log::debug!("query_order: client_order_id={}", cmd.client_order_id);
let algo_lookup = self.resolve_algo_lookup(Some(cmd.client_order_id), cmd.params.as_ref());
let http_client = self.http_client.clone();
let command = cmd;
let emitter = self.emitter.clone();
let account_id = self.core.account_id;
let clock = self.clock;
let symbol = format_binance_symbol(&command.instrument_id);
let order_id = command
.venue_order_id
.map(|id| {
id.inner()
.parse::<i64>()
.map_err(|e| anyhow::anyhow!("failed to parse venue_order_id: {e}"))
})
.transpose()?;
let orig_client_order_id = Some(encode_broker_id(
&command.client_order_id,
BINANCE_NAUTILUS_FUTURES_BROKER_ID,
));
let (price_precision, size_precision) =
self.get_instrument_precision(command.instrument_id)?;
let treat_expired_as_canceled = self.config.treat_expired_as_canceled;
let use_position_ids = self.config.use_position_ids;
self.spawn_task("query_order", async move {
if algo_lookup == BinanceFuturesAlgoLookup::AlgoId {
match http_client
.query_algo_order_with_history(
command.instrument_id,
Some(command.client_order_id),
command.venue_order_id,View on GitHub (pinned to 18893faf8b)