Modify Order(v2)
Interface description
Function description: Modify equity orders, including simple orders. Support modify orderType, quantity, price, timeInForce.
Request URL:
/openapi/account/orders/replace?account_id={account_id}
Request method: POST
Frequency limit: The calling frequency of each AppId is limited to 1 time per second.
Parameters
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
account_id | String | Required | Account ID | CASH_10004248 |
modify_orders | []order_item | Required | Order Details |
order_item:
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
client_order_id | String | Required | User-defined order ID. | 0KGOHL4PR2SLC0DKIND4TI0002 |
time_in_force | String | Optional | Time In Force | DAY |
stop_price | String | Optional | Stop Price for Stop or StopLimit order. When the market price is greater than or equal to 1, the precision is 2, and when the market price is less than 1, the precision is 4 | 11.00 |
limit_price | String | Optional | Limit Price for Limit or StopLimit order. When the market price is greater than or equal to 1, the precision is 2, and when the market price is less than 1, the precision is 4 | 11.00 |
quantity | String | Optional | The number of units. | 1 |
close_contracts | []CloseContract | Optional | List of contracts, if the position is closed with the field passed in, the position will be closed according to the contract dimension. If contract id is not passed, the position will be closed according to the first-in-first-out rule. |
close_contracts:
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
contract_id | String | No | Contract id | 2022021819071234 |
quantity | String | No | The quantities of orders to be closed under each contract ID. The original value will be taken without modification, and the modified value will be passed if modification is required. | 10 |
Response
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
client_order_id | String | Required | client_order_id to cancel | 0KGOHL4PR2SLC0DKIND4TI0002 |
order_id | String | Required | Order id Simple order return, Webull order ID. | 80HG7CPSFDPCAL3TP66LKBAS69 |
Request example
- python
- Java
from webullsdkcore.client import ApiClient
from webullsdktrade.api import API
api_client = ApiClient(your_app_key, your_app_secret, Region.JP.value)
api = API(api_client)
modify_orders = {
"client_order_id": client_order_id,
"quantity": "100",
"limit_price": "2090"
}
res = api.order_v2.replace_order(account_id=account_id, modify_orders=modify_orders)
if res.status_code == 200:
print("replace_order_res=" + json.dumps(res.json(), indent=4))
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.jp.name())
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
TradeOrder modifyTradeOrder = new TradeOrder();
List<TradeOrderItem> modifyOrders = new ArrayList<>();
TradeOrderItem modifyOne = new TradeOrderItem();
modifyOne.setClientOrderId(tradePlaceOrderResponse.getClientOrderId());
modifyOne.setLimitPrice("45");
modifyOne.setQuantity("100");
modifyOrders.add(modifyOne);
modifyTradeOrder.setModifyOrders(modifyOrders);
TradeOrderResponse tradeReplaceOrderResponse = apiService.replaceOrderV2(accountId, modifyTradeOrder);