Cancel or Modify Orders

cancel_order Cancel Order

TradeClient.cancel_order(account=None, id=None, order_id=None)

Description

Cancel a previously submitted order. Order cancellation, like order placement, is processed asynchronously. Calling this method confirms that the cancellation request has been successfully sent, but the final cancellation result will be handled asynchronously by the system.

After submitting an order via TradeClient.place_order, the order may transition through several states depending on market and system conditions:

  • Orders that are fully filled or rejected cannot be canceled
  • Only orders in submitted or partially filled states are eligible for cancellation

For details on possible order states, please refer to TradeClient.get_order.

To cancel multiple orders, useTradeClient.get_open_orders to retrieve all pending orders, then submit cancellation requests individually. If an order has already been submitted for cancellation, do not resend the request. After issuing a cancellation request, wait briefly and re-query open orders to confirm the updated status.

Parameters

ParameterTypeRequiredDescription
accountstrNoAccount ID. If not provided, the default account from client_config is used
idintYesGlobal order ID. Recommended for order cancellation. Obtain this value from Order.id after placing an order
order_idintNoLocal order ID. Obtain this value from Order.order_id

Example

from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

trade_client = TradeClient(client_config)

# Assuming order id is 26731241425469440
trade_client.cancel_order(id=26731241425469440)

modify_order 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 an existing, submitted order.

Note: Order type cannot be changed. Only the fields listed below can be modified, and field availability depends on the original order type.

Parameters

Parameter

Type

Required

Description

order

Order

Yes

The Order object to be modified (tigeropen.trade.domain.order.Order)

quantity

int

No

Updated order quantity

limit_price

float

No

Updated limit price.
Required when the order type is LMT, STP_LMT

aux_price

float

No

Auxiliary price:

  • Trigger price for stop-limit orders

Required when the order type is LMT, STP_LMT

percent_offset

float

No

Percentage offset for order price calculation (if supported by the order type)

time_in_force

str

No

Order validity period

  • DAY — valid for the current trading day
  • GTC — good until canceled

Defaults to DAY

outside_rth

bool

No

Whether to allow pre‑market and after‑hours trading (US stocks only)

Example

from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

trade_client = TradeClient(client_config)

# Assuming order id is: 26731241425469440
order = trade_client.get_order(id=26731241425469440)
trade_client.modify_order(order, quantity=2, limit_price=105.0)