Replace Order
Interface Description
Function description: Modify order.
Note: The order interface must be successfully called before modifying the order.
Applicable objects: Customers who connect to Webull through the OpenApi development platform.
Request URL: /trade/order/replace
Request method: POST
Frequency limit: The calling frequency of each AppId is limited to 1 time per second.
Request parameters
Note: Only the quantity and price are allowed to be modified (the original value will be passed to the quantity and price fields that do not need to be modified).
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
account_id | String | Yes | Account ID | 20150320010101001 |
stock_order | {}stock_order | Yes | Stock order parameters | See example codes |
stock_order:
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
client_order_id | String | Yes | WEBULL system internal orderId. | 2022021819071234 |
order_type | String | Yes | Order type must be passed and not allowed to be modified referring to the dictionary value OrderType. | MARKET |
limit_price | String | No | It needs to be passed for order_type of LIMIT (limit order), STOP_LOSS_LIMIT (stop-loss limit order). If it is not modified, it will carry the original value, and if it needs to be modified, the modified value will be passed. | 100.49 |
qty | String | No | The number of equities should be an integer, and the maximum value supported is 1,000,000 shares. The original value will be taken without modification, and the modified value will be passed if modification is required. | 100 |
stop_price | String | No | When order_type is STOP_LOSS (stop-loss order), STOP_LOSS_LIMIT (stop-loss limit price), it needs to be passed, and the original value will be passed if it does not need to be modified, and the modified value will be passed if it needs to be modified. | 100.49 |
close_contracts | []CloseContract | No | 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. For margin account only. |
close_contracts:
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
contract_id | String | No | Contract id | 2022021819071234 |
qty | 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
Parameter | Type | Description | Example value |
---|---|---|---|
client_order_id | String | WEBULL system internal orderId | 0324PS4NN26DU0KHJR7S000000 |
Request example
- Python
- Java
from webullsdktrade.api import API
from webullsdkcore.client import ApiClient
from webullsdkcore.common.region import Region
api_client = ApiClient(your_app_key, your_app_secret, Region.JP.value)
api = API(api_client)
stock_order = {
"client_order_id": "2343512312312312",
"order_type": "LIMIT",
"limit_price": "485.100",
"close_contracts": [
{
"contract_id": "MCH6VT35A9OFA4DVNOBGEE98JA",
"qty": "2"
}
]
}
response = api.order.replace_order_v2(account_id, stock_order)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.jp.name())
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
StockOrder stockOrder = new StockOrder();
stockOrder.setClientOrderId(clientOrderId);
stockOrder.setLimitPrice(limitPrice);
stockOrder.setQty(qty);
stockOrder.setStopPrice(stopPrice);
stockOrder.setCloseContracts(closeContracts);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);