Skip to main content

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

ParameterTypeRequired fieldsDescriptionExample value
account_idStringYesAccount ID20150320010101001
stock_order{}stock_orderYesStock order parametersSee example codes

stock_order:

ParameterTypeRequired fieldsDescriptionExample value
client_order_idStringYesWEBULL system internal orderId.2022021819071234
order_typeStringYesOrder type must be passed and not allowed to be modified referring to the dictionary value OrderType.MARKET
limit_priceStringNoIt 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
qtyStringNoThe 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_priceStringNoWhen 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[]CloseContractNoList 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:

ParameterTypeRequired fieldsDescriptionExample value
contract_idStringNoContract id2022021819071234
qtyStringNoThe 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

ParameterTypeDescriptionExample value
client_order_idStringWEBULL system internal orderId0324PS4NN26DU0KHJR7S000000

Request example

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

Response example

Exception example