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
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | string | Yes | User authorized account: DU575569 |
| id | long | Yes | Order ID returned when placing order |
| secret_key | string | No | Trader secret key, for institutional users only |
Response
| Name | Type | Description |
|---|---|---|
| id | long | Unique 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | string | Yes | User authorized account: DU575569 |
| id | long | Yes | Order ID returned when placing order |
| total_quantity | long | No | Order quantity (Callable bull/bear contracts have minimum quantity restrictions) |
| total_quantity_scale | int | No | Order 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_price | double | No | Limit price, required when order_type is LMT, STP, STP_LMT |
| aux_price | double | No | Stock stop price. Required when order_type is STP, STP_LMT. |
| secret_key | string | No | Trader secret key, for institutional users only |
Response
| Name | Type | Description |
|---|---|---|
| id | long | Unique 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
}
}Updated 7 days ago