Cancel or Modify Orders

Cancel Order

Request class: TigerHttpRequest(MethodName.CANCEL_ORDER)

Description

Cancel a placed order. Cancellation is asynchronous. A successful response contains only the order ID in data and confirms that the request was accepted; it does not mean the order has been canceled. Query the order afterward and check both status and cancelStatus. Use them together to determine the final result.

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: DU000001
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("DU000001")
    .id(100000000000000001L)
    .buildJson();

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

Example Response

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

Rate Limit

The base rate limit is 120 requests/min.


Modify Order

Request class: TigerHttpRequest(MethodName.MODIFY_ORDER)

Description

Modification rules depend on the account and original order type:

  • Global accounts: There is no universal rule that every request must explicitly contain at least one changed field or that order_type can never be supplied. Supported fields and omission behavior depend on the original order type. Supply only fields supported for that order.
  • Prime/Paper accounts: The original order type determines how the modification is handled; order_type cannot convert the order to another type. Orders such as LMT, STP, STP_LMT, and TRAIL require an effective quantity, price, or trailing parameter appropriate to the original order type. See the table below.

Zero and omission are handled by account path:

Account pathtotal_quantity=0Applicable price field is 0order_typeOmitted time_in_force
GlobalRetains the original quantity when the resulting request has order_type=LMTRetains the original limit price when the resulting request has order_type=LMTAn explicit value is retained; omission copies the original order typeCompleted as DAY
Prime/PaperNot sent as a new quantityLMT/STP/STP_LMT/TRAIL prices are not sent as new values; multi-leg orders may use negative pricesThe service queries and enforces the original order typeCompleted as DAY

A Prime/Paper standard-order request must contain at least one quantity, price, or trailing change effective for the original order type. An Iceberg request may change only display sizes, check intervals, or effective times in algo_params; see the rules below.

Parameters

ParameterTypeRequiredDescription
accountstringYesUser authorized account: DU000001
idlongYesOrder ID returned when placing order
order_typestringNoIts use for Global accounts depends on the original order; Prime/Paper uses the queried original order type and cannot use this field to convert the order type
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_pricedoubleNoNew limit price for a standard order whose original type is LMT or STP_LMT. Required combinations depend on the account and original order type. Prime/Paper Iceberg modification does not support this field
aux_pricedoubleNoNew stop price when the original order is STP or STP_LMT; trailing amount when it is TRAIL. Required combinations depend on the account and original order type
trailing_percentdoubleNoFor an original TRAIL order, provide aux_price or trailing_percent; when both are supplied, trailing_percent takes priority
cash_amountdoubleNoOrder amount modification is unsupported. Prime/Paper rejects a request containing this field; do not submit it as a modifiable field for Global accounts either
display_sizeintNoDisplay quantity for Prime/Paper Iceberg modification only
min_display_sizeintNoMinimum display quantity for Prime/Paper Iceberg modification only
check_intervalsintNoPrice check interval in seconds for Prime/Paper Iceberg modification only
price_typestringNoPrime/Paper Iceberg modification currently does not support changing this field
start_timelongNoThis top-level field is not used for Iceberg modification. For Prime/Paper Iceberg orders, put start_time in algo_params as a Unix timestamp in milliseconds
end_timelongNoThis top-level field is not used for Iceberg modification. For Prime/Paper Iceberg orders, put end_time in algo_params as a Unix timestamp in milliseconds
algo_paramsList<TagValue>NoFor Prime/Paper Iceberg effective-time changes, include start_time and/or end_time in this list
secret_keystringNoTrader secret key, for institutional users only
📝

Prime/Paper Iceberg modification: You can modify total_quantity, display_size, min_display_size, check_intervals, and start_time or end_time supplied through algo_params. Changing limit_price or price_type is unsupported. Top-level start_time and end_time are not used for Iceberg modification. Global accounts are outside this support scope.

TradeParamBuilder has no convenience methods for display_size, min_display_size, check_intervals, price_type, start_time, or end_time. algo_params is available through TradeParamBuilder.algoParams(...); Iceberg effective times must be nested there. The current builder has no corresponding display-field modification methods.

To modify display-related fields, construct the biz_content JSON manually and submit it through TigerHttpRequest.setBizContent(...); do not place these fields in algo_params:

JSONObject params = new JSONObject();
params.put("account", "DU000001");
params.put("id", 100000000000000001L);
params.put("display_size", 100);
params.put("min_display_size", 50);
params.put("check_intervals", 30);

TigerHttpRequest request = new TigerHttpRequest(MethodName.MODIFY_ORDER);
request.setBizContent(params.toJSONString());

The response contains only the order ID in data and does not report the final replacement state. Query the order and check both status and replaceStatus. replaceStatus=REPLACED means the replacement was confirmed, while replaceStatus=FAILED means it failed. Continue querying other intermediate states and interpret them together with the order status.

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);

// Assume this ID belongs to an existing modifiable LMT or STP_LMT order.
String bizContent = TradeParamBuilder.instance()
    .account("DU000001")
    .id(100000000000000001L)
    .totalQuantity(200L)
    .limitPrice(60.0)
    .buildJson();

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

Example Response

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

Rate Limit

The base rate limit is 120 requests/min.


Did this page help you?