Cancel or Modify Orders
Initialization
All examples on this page assume the following initialization has been completed:
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='your_config_directory_path')
trade_client = TradeClient(client_config)For details, see Prerequisites.
Cancel Order
TradeClient.cancel_order(account=None, id=None, order_id=None)
Description
Cancel a submitted order. Like order placement, cancellation is asynchronous: a successful call confirms only that the request was submitted.
After submitting an order using TradeClient.place_order, the submitted order will enter various states depending on different circumstances. Orders that have been filled or rejected by the system cannot be canceled. Only orders in submitted or partially filled states can be canceled. See TradeClient.get_order for possible order states.
For batch orders, use TradeClient.get_open_orders to retrieve pending orders and cancel them individually. Do not submit another cancellation request for an order already pending cancellation. Wait briefly after the request, then check the pending orders again.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID, if not provided, the default account from client_config will be used |
| id | int | Yes | Global order ID. The id field is recommended for cancellation operations. After place_order, obtain it from Order.id |
| order_id | int | No | Local order_id, can be obtained through Order.order_id |
Returns
Returns the global order ID (int) when the cancellation request is submitted successfully; otherwise raises ApiException. Cancellation is asynchronous, so a returned ID does not mean the order is already canceled. Poll get_order until the order reaches CANCELLED or another final state, such as a fill that completed before cancellation; do not treat request acceptance as completion.
Example
# Assuming order id is 26731241425469440
trade_client.cancel_order(id=26731241425469440)Rate Limit
The base rate limit is 120 requests/minute.
Modify Order
TradeClient.modify_order(order, quantity=None, limit_price=None, aux_price=None, trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None, outside_rth=None, **kwargs)
Description
Modify a submitted order. Order type modification is not supported. See the table below for specific modifiable fields.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| order | Order | Yes | The Order object to be modified (tigeropen.trade.domain.order.Order) |
| quantity | int | No | New quantity; omission copies order.quantity |
| limit_price | float | No | New limit price; omission copies order.limit_price |
| aux_price | float | No | Stop trigger price or trailing amount; omission copies order.aux_price |
| trail_stop_price | float | No | New trailing-stop activation price; omission copies order.trail_stop_price |
| trailing_percent | float | No | New trailing percentage; omission copies order.trailing_percent |
| percent_offset | float | No | New percentage offset; omission copies order.percent_offset |
| time_in_force | str | No | DAY (valid for the day), GTC (valid until canceled), or GTD (valid until the specified time); omission copies order.time_in_force |
| outside_rth | bool | No | Whether extended-hours execution is allowed; omission copies order.outside_rth |
The trailing-stop fields are resolved independently, not as mutually exclusive parameters: an explicit argument takes precedence over the same field on the original order, while an omitted argument is copied from that order. For a TRAIL order with both a nonzero trailing_percent and aux_price, the server gives trailing_percent precedence; trail_stop_price and percent_offset are still passed independently.
An explicit numeric 0 is preserved in the outgoing request; the server then applies the original-order rules for the Global or Prime/Paper path.
Returns
Returns the global order ID (int) when the modify request is submitted; otherwise raises ApiException. The ID is not final confirmation. Continue querying the order and confirm that the new terms took effect or that the order reached a final state before treating the modification as complete.
Example
# Assuming order id is: 26731241425469440
order = trade_client.get_order(id=26731241425469440)
trade_client.modify_order(order, quantity=2, limit_price=105.0)Rate Limit
The base rate limit is 120 requests/minute.
Updated about 1 month ago
