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). Other parameters must be the same as the original order, which needs to be passed but cannot be changed.
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 | The third-party order ID is unique with the account ID. The maximum length of the input parameter in this field is 40. It must be passed and cannot be modified. | 2022021819071234 |
side | String | Yes | Referring to the dictionary value OrderSide, we currently only supports BUY and SELL, which must be passed and cannot be modified. | BUY |
tif | String | Yes | The validity period of the order, refer to the dictionary value OrderTIF, currently only DAY is supported, must be passed and cannot be modified | DAY |
extended_hours_trading | Boolean | Yes | Whether to allow pre-market and post-market trading. The market order can only be false; the limit order can be true or false, and must not be modified. | false |
instrument_id | String | Yes | The ID of the equity which the caller obtains by calling Get Instruments must be passed and modification is not allowed. | 12064446 |
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), ENHANCED_LIMIT (enhanced limit order), AT_AUCTION_LIMIT (at-auction 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 | Yes | 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 |
trailing_type | String | No | Modifications are not allowed for spread type of trailing stop order referring to TrailingType , and trailing stop orders have to be transmitted. | AMOUNT |
trailing_stop_step | String | No | The value of the price difference of the trailing stop order, the trailing stop order should be transmitted, and the original value will be carried if it does not need to be modified, and the modified value will be transmitted if it needs to be modified. | 100.49 |
Response Parameter
Parameter | Type | Description | Example value |
---|---|---|---|
client_order_id | String | The 3rd party order ID | 2022021819071234 |
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.HK.value)
api = API(api_client)
response = api.order.replace_order(account_id, qty, instrument_id, side, client_order_id, order_type,
extended_hours_trading, tif, limit_price, stop_price,
trailing_type, trailing_stop_step)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.hk.name())
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
StockOrder stockOrder = new StockOrder();
stockOrder.setClientOrderId(clientOrderId);
stockOrder.setSide(side);
stockOrder.setTif(tif);
stockOrder.setExtendedHoursTrading(extendedHoursTrading);
stockOrder.setInstrumentId(instrumentId);
stockOrder.setOrderType(orderType);
stockOrder.setLimitPrice(limitPrice);
stockOrder.setQty(qty);
stockOrder.setStopPrice(stopPrice);
stockOrder.setTrailingType(trailingType);
stockOrder.setTrailingStopStep(trailingStopStep);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);