nautechsystems/nautilus_trader · error · anyhow::Error

failed to parse venue_order_id: {e}

Error message

failed to parse venue_order_id: {e}

What it means

The adapter converts the QueryOrder command's VenueOrderId into the integer orderId required by the Binance Futures REST API (GET /fapi/v1/order or /dapi/v1/order). Binance futures order IDs are numeric strings; when the provided venue_order_id does not parse as i64 (letters, dashes, IDs from another venue, corrupted cache values), submission fails locally with this message before any HTTP request is made.

Source

Thrown at crates/adapters/binance/src/futures/execution.rs:2314

    }

    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;

        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 a4b06ed870)

Solutions

  1. Omit venue_order_id on the query so the adapter resolves the order via origClientOrderId (client_order_id)
  2. Verify the ID originated from a Binance Futures order acknowledgment or fill (numeric string)
  3. Check strategy routing so the query reaches the execution client that owns the order
  4. If the cache may be stale, run reconciliation first so venue order IDs are repopulated

Example fix

// before — venue_order_id from a non-Binance system
let venue_order_id = Some(VenueOrderId::new("oid-abc-123"));

// after — omit it; the adapter queries by origClientOrderId
let venue_order_id = None; // client_order_id must be set on the command
Defensive patterns

Strategy: validation

Validate before calling

// Before sending QueryOrder to the Binance Futures client
if let Some(vid) = cmd.venue_order_id.as_ref() {
    if vid.inner().parse::<i64>().is_err() {
        // Non-numeric ID: clear it so the adapter queries by origClientOrderId
        cmd.venue_order_id = None;
    }
}

Type guard

fn is_binance_numeric_venue_id(id: &VenueOrderId) -> bool {
    id.inner().parse::<i64>().is_ok()
}

Try / catch

On an error containing 'failed to parse venue_order_id', re-issue the query with venue_order_id cleared so the adapter resolves the order by client_order_id.

Prevention

When it happens

Trigger: Sending QueryOrder to the Binance Futures execution client with a venue_order_id whose inner string is not a valid i64 — e.g. an ID minted by a different venue adapter, a hand-crafted placeholder in tests, or a stale cache entry.

Common situations: Multi-venue strategies routing queries to the wrong execution client; test suites using placeholder IDs; replaying recorded IDs with formatting applied; mixed spot/futures setups where ID formats differ.

Understand the failure class

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/d9564d7fe6c935cf. Report an issue: GitHub.