Replace Order
replace_orderModify an open order's quantity, price, trigger price, or trailing parameters, including attached take-profit/stop-loss legs. Requires a two-step dry-run confirmation before changes are sent to the exchange.
Instructions
Modify an open order's quantity, price, trigger_price, or trailing params. Returns "order replaced" on success. Only open/pending orders can be modified. TWO-STEP CONFIRMATION IS MANDATORY: this tool is a DRY RUN unless you pass the confirmation_code its own dry run returned. Call it first without execute, show the returned preview to the user, and only call it again with execute="" after the user has explicitly confirmed that exact order. The code is derived from the order itself, so it applies only to that exact order. Never quote it back on your own initiative, and never in the same turn the user first asks. The dry run echoes the current order alongside the requested change. Attached take-profit/stop-loss legs are changed here too: attached_order_type with the new attached_profit_taker_price / attached_stop_loss_price adds or reprices a leg, attached_profit_taker_id / attached_stop_loss_id target an existing leg, and attached_cancel_all=true removes every leg while leaving the order in place.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| _jq | No | Optional jq filter (jaq syntax) applied to this tool's JSON response before it is returned; it never changes the upstream request. One output is returned as-is, several as a JSON array, none as []. Module imports and the `env`/`debug`/`stderr` builtins are unavailable. Example: .data | map({symbol}). Omit for the full response. | |
| price | No | New limit price (for limit-style orders) | |
| execute | No | The `confirmation_code` from this order's dry run. WITHOUT IT NOTHING IS SENT. Omitted (the default) makes this a DRY RUN: the request is validated and echoed back with a three-digit `confirmation_code`, and nothing reaches the exchange. Required protocol: call once without `execute`, show the returned preview to the user, and call again quoting the code only after the user has explicitly confirmed that exact order. The code is single use, expires in 10 minutes, and applies only to this exact order — change any field and it stops working. Never quote it back on your own initiative, and never in the same turn the user first asks. | |
| order_id | Yes | Order ID to replace (returned by submit_order or listed in today_orders / history_orders) | |
| quantity | Yes | New order quantity (number of shares) | |
| limit_offset | No | New limit offset from the trailing stop price (for TSLPAMT / TSLPPCT) | |
| trigger_price | No | New trigger (activation) price (for LIT / MIT / trailing-stop orders) | |
| trailing_amount | No | New trailing amount as absolute price distance (for TSLPAMT) | |
| attached_main_id | No | ID of the parent order that owns the attached leg, when the leg is modified on its own rather than through its parent. | |
| trailing_percent | No | New trailing percent as decimal e.g. 0.05 = 5% (for TSLPPCT) | |
| attached_quantity | No | New quantity for the attached leg. | |
| attached_cancel_all | No | Set to true to cancel every attached take-profit / stop-loss leg of this order, leaving the order itself in place. | |
| attached_order_type | No | Attached leg to add or update: "PROFIT_TAKER", "STOP_LOSS" or "BRACKET". Required unless the only attached change is attached_cancel_all. | |
| attached_expire_time | No | New expiry for the attached leg as a unix timestamp in seconds. Required when attached_time_in_force is GTD. | |
| attached_outside_rth | No | New outside-RTH setting for the triggered leg: "RTH_ONLY" / "ANY_TIME" / "OVERNIGHT" / "OPTION_PRE_MARKET". | |
| attached_market_price | No | Reference market price for the attached leg. | |
| attached_stop_loss_id | No | ID of the existing stop-loss leg to update (from order_detail's attached_orders[]). Omit to add a new leg. | |
| attached_time_in_force | No | New time-in-force for the attached leg: "Day" / "GTC" / "GTD". | |
| attached_profit_taker_id | No | ID of the existing take-profit leg to update (from order_detail's attached_orders[]). Omit to add a new leg. | |
| attached_stop_loss_price | No | New stop-loss trigger price. | |
| attached_profit_taker_price | No | New take-profit trigger price. | |
| attached_activate_order_type | No | New order type for the triggered leg, e.g. "LO" or "MO". | |
| attached_stop_loss_submit_price | No | New limit price for the stop-loss leg. | |
| attached_profit_taker_submit_price | No | New limit price for the take-profit leg. |