{"record":{"id":"f6a4daa01290d58c","repo":"nautechsystems/nautilus_trader","slug":"venue-order-id-required-for-modify","errorCode":null,"errorMessage":"venue_order_id required for modify","messagePattern":"venue_order_id required for modify","errorType":"validation","errorClass":"BinanceSpotHttpError","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":1690,"sourceCode":"            self.spawn_task(\"modify_order_http\", async move {\n                let result = match command.venue_order_id {\n                    Some(venue_order_id) => {\n                        http_client\n                            .modify_order(\n                                account_id,\n                                command.instrument_id,\n                                venue_order_id,\n                                command.client_order_id,\n                                order_side,\n                                order_type,\n                                quantity,\n                                time_in_force,\n                                command.price,\n                                use_gtd,\n                            )\n                            .await\n                    }\n                    None => Err(anyhow::anyhow!(BinanceSpotHttpError::ValidationError(\n                        \"venue_order_id required for modify\".to_string()\n                    ))),\n                };\n\n                match result {\n                    Ok(report) => {\n                        let ts_now = clock.get_time_ns();\n                        let updated_event = OrderUpdated::new(\n                            trader_id,\n                            command.strategy_id,\n                            command.instrument_id,\n                            command.client_order_id,\n                            report.quantity,\n                            UUID4::new(),\n                            ts_now,\n                            ts_now,\n                            false,\n                            Some(report.venue_order_id),","sourceCodeStart":1672,"sourceCodeEnd":1708,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/execution.rs#L1672-L1708","documentation":"On the HTTP modify path, Binance Spot modification is a cancel-replace keyed by the venue's numeric order ID; when the `ModifyOrder` command carries `venue_order_id = None` the adapter cannot build the request and short-circuits with `BinanceSpotHttpError::ValidationError(\"venue_order_id required for modify\")`. This is a local failure (no request is sent), classified by `is_local_command_failure`, so it surfaces to the strategy as an `OrderModifyRejected` event with reason 'modify-order-error: venue_order_id required for modify'.","triggerScenarios":"Calling `modify_order` while WS trading is not active with a `ModifyOrder` whose `venue_order_id` is None — typically because the strategy constructed the command identifying the order only by `client_order_id`, or because the order has not yet been acknowledged by Binance (no venue ID assigned yet).","commonSituations":"Modifying immediately after submitting (before OrderAccepted/Updated carries the venue_order_id); replaying or simulating live strategies where ModifyOrder objects were created without venue IDs; strategies ported from venues whose amend API keys on client order ID instead of venue order ID.","solutions":["Wait for the order to be acknowledged (OrderSubmitted → OrderAccepted/OrderUpdated with a venue_order_id) before sending ModifyOrder","Populate `venue_order_id` on the ModifyOrder command (look it up from the cached order) when building the command yourself","Enable the WS trading transport, whose cancel-replace params can fall back to the client order ID when the venue ID is absent"],"exampleFix":"# before\nmodify = ModifyOrder(\n    trader_id=self.trader_id,\n    strategy_id=self.id,\n    instrument_id=order.instrument_id,\n    client_order_id=order.client_order_id,\n    venue_order_id=None,  # rejected: HTTP modify keys on the venue ID\n    quantity=new_qty,\n    price=new_price,\n    command_id=UUID4(),\n    ts_init=self.clock.timestamp_ns(),\n)\n\n# after\nmodify = ModifyOrder(\n    trader_id=self.trader_id,\n    strategy_id=self.id,\n    instrument_id=order.instrument_id,\n    client_order_id=order.client_order_id,\n    venue_order_id=order.venue_order_id,  # assigned after venue acknowledgment\n    quantity=new_qty,\n    price=new_price,\n    command_id=UUID4(),\n    ts_init=self.clock.timestamp_ns(),\n)","handlingStrategy":"validation","validationCode":"# Python: guard before submitting the modify (HTTP path requires the venue ID)\norder = self.cache.order(client_order_id)\nif order is None:\n    self.log.error(f\"Order {client_order_id} not in cache; cannot modify\")\n    return\nif order.venue_order_id is None:\n    self.log.info(\n        f\"Order {client_order_id} not yet acknowledged by venue; deferring modify\"\n    )\n    return  # retry after the next OrderAccepted/OrderUpdated event\nself.request(modify_command)","typeGuard":"# Python\ndef is_modifiable_on_venue(order) -> bool:\n    \"\"\"True when the order carries a venue-assigned ID (required for HTTP modify).\"\"\"\n    return order.venue_order_id is not None and order.is_open","tryCatchPattern":"# Python: the failure arrives as an event, not an exception — handle the rejection\nself.msgbus.subscribe(\"events.order.modify_rejected\", handler)\n\ndef handler(event):\n    if \"venue_order_id required for modify\" in str(event.reason):\n        # order not yet acknowledged; re-queue the modify for after acknowledgment\n        ...","preventionTips":["Only modify orders whose venue_order_id is populated (i.e., after the venue acknowledged the submit)","Derive ModifyOrder fields from the cached order instead of rebuilding them by hand","If your strategy amends aggressively right after submit, enable WS trading so the cancel-replace can key on the client order ID","Unit-test the modify flow against a sandbox where venue IDs are assigned asynchronously"],"tags":["binance-spot","modify-order","validation","venue-order-id","nautilustrader"],"backgroundTag":"missing-required-request-field","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}