nautechsystems/nautilus_trader · error

Cannot modify order without venue_order_id

Error message

Cannot modify order without venue_order_id

What it means

Betfair orders are identified by a venue-assigned bet_id (VenueOrderId). Modifying an order requires that id because Betfair's placeOrders replacement flow targets existing bets by betId. The execution client throws this when a ModifyOrder command arrives without a venue_order_id, e.g. one generated before the order was acknowledged by the venue.

Solutions

  1. Wait for the order's venue_order_id (OrderAccepted event) before issuing ModifyOrder.
  2. Verify the command targets the Betfair execution client that owns the order (get_order by client_order_id to confirm it exists and is acknowledged).
  3. Cancel and resubmit the order with the desired price/quantity if the venue id is genuinely unavailable.

Example fix

// before
let cmd = ModifyOrder::new(instrument_id, client_order_id, None, None, None);
exec_client.modify_order(cmd)?; // panics/errors: no venue_order_id

// after
let venue_order_id = portfolio.query_venue_order_id(&client_order_id)?; // after OrderAccepted
let cmd = ModifyOrder::new(instrument_id, client_order_id, Some(venue_order_id), Some(new_price), None);
exec_client.modify_order(cmd)?;
Defensive patterns

Strategy: validation

Validate before calling

if cmd.venue_order_id.is_none() {
    return Err(anyhow!("refusing to modify order {}: no venue_order_id yet", cmd.client_order_id));
}

Type guard

fn is_modifiable(cmd: &ModifyOrder) -> bool { cmd.venue_order_id.is_some() }

Prevention

When it happens

Trigger: Calling modify_order on a BetfairExecutionClient with a command whose cmd.venue_order_id is None — typically an order submitted but not yet confirmed by the venue, or a modification routed to the wrong client.

Common situations: Submitting a modify immediately after submit_order without waiting for the OrderAccepted/OrderUpdated event that carries the venue_order_id; replaying commands from persistence where the venue id was never persisted; using a client_order_id-only workflow.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/b4f24b6afe5760d2. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/betfair/src/execution.rs:2441

                    );
                }
            }

            Ok(())
        });

        Ok(())
    }

    fn modify_order(&self, cmd: ModifyOrder) -> anyhow::Result<()> {
        self.process_pending_resync();

        let instrument_id = cmd.instrument_id;
        let market_id = extract_market_id(&instrument_id)?;

        let venue_order_id = cmd
            .venue_order_id
            .ok_or_else(|| anyhow::anyhow!("Cannot modify order without venue_order_id"))?;
        let bet_id: BetId = venue_order_id.to_string();

        // Compare against existing order to determine actual changes
        let existing_order = self.core.get_order(&cmd.client_order_id);
        let has_price_change = match (&cmd.price, &existing_order) {
            (Some(new_price), Ok(order)) => order.price() != Some(*new_price),
            (Some(_), Err(_)) => true,
            (None, _) => false,
        };
        let has_quantity_change = match (&cmd.quantity, &existing_order) {
            (Some(new_qty), Ok(order)) => order.quantity() != *new_qty,
            (Some(_), Err(_)) => true,
            (None, _) => false,
        };

        // Betfair does not support atomic price+quantity modification
        if has_price_change && has_quantity_change {
            let ts_event = self.clock.get_time_ns();

View on GitHub (pinned to 18893faf8b)