中文

Cancel or Modify Orders

Cancel Order

Corresponding request class: TigerHttpRequest(MethodName.CANCEL_ORDER)

Description

Cancel a placed order. Order cancellation, similar to order placement, is executed asynchronously. After calling this command, it indicates that the cancellation request has been sent successfully, and the cancellation execution will be processed asynchronously.

After submitting an order using TradeOrderRequest, the submitted order will enter various states depending on different circumstances. Orders that have already been filled or rejected by the system cannot be canceled. Only orders in submitted or partially filled status can be canceled. Please refer to the description of the TigerHttpRequest(MethodName.ORDERS) method to understand the possible order states.

For batch orders, you can use TigerHttpRequest(MethodName.ACTIVE_ORDERS) to get the list of pending orders and cancel them one by one. For orders that have already been requested for cancellation, do not repeat the request. After executing the cancellation command, wait for a period of time and then check the pending orders again.

Parameters

ParameterTypeRequiredDescription
accountstringYesUser authorized account: DU575569
idlongYesOrder ID returned when placing order
secret_keystringNoTrader secret key, for institutional users only

Response

NameTypeDescription
idlongUnique order ID, can be used to query/modify/cancel orders

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
TigerHttpRequest request = new TigerHttpRequest(MethodName.CANCEL_ORDER);

String bizContent = TradeParamBuilder.instance()
    .account("DU575569")
    .id(147070683398615040L)
    .buildJson();

request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);
JSONObject data = JSON.parseObject(response.getData());
Long id = data.getLong("id");

Response Example

{
  "code": 0,
  "message": null,
  "timestamp": 1525938835697,
  "data": {
      "id":147070683398615040
  }
}

Modify Order

Corresponding request class: TigerHttpRequest(MethodName.MODIFY_ORDER)

Description

Modify an order. Order type modification is not supported.

Parameters

ParameterTypeRequiredDescription
accountstringYesUser authorized account: DU575569
idlongYesOrder ID returned when placing order
total_quantitylongNoOrder quantity (Hong Kong stocks, Shanghai-Hong Kong Stock Connect, warrants, and callable bull/bear contracts have minimum quantity restrictions)
total_quantity_scaleintNoOrder quantity offset, default is 0. For odd lot orders, total_quantity and total_quantity_scale combine to represent the actual order quantity, e.g., total_quantity=111 total_quantity_scale=2, then actual quantity=111*10^(-2)=1.11
limit_pricedoubleNoLimit price, required when order_type is LMT, STP, STP_LMT
aux_pricedoubleNoStock stop price. Required when order_type is STP, STP_LMT. When order_type is TRAIL, this is the trailing amount
trailing_percentdoubleNoTrailing stop order percentage. When order_type is TRAIL, aux_price and trailing_percent are mutually exclusive, with trailing_percent taking priority
secret_keystringNoTrader secret key, for institutional users only

Response

NameTypeDescription
idlongUnique order ID, can be used to query/modify/cancel orders

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
TigerHttpRequest request = new TigerHttpRequest(MethodName.MODIFY_ORDER);

String bizContent = TradeParamBuilder.instance()
    .account("DU575569")
    .id(147070683398615040L)
    .totalQuantity(200)
    .limitPrice(60.0)
    .buildJson();

request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);
JSONObject data = JSON.parseObject(response.getData());
Long id = data.getLong("id");

Response Example

{
  "code": 0,
  "message": null,
  "timestamp": 1525938835697,
  "data": {
      "id":147070683398615040
  }
}