Replace Order
Interface Description
Function description: Modify order.
Note: The order interface must be successfully called before modifying the order.
Applicable objects: Customers who integrate into Webull through Webull OpenAPI.
Request URL: /trade/order/replace
Request method: POST
Frequency limit: The calling frequency of each App ID 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 | Client order ID. Must be the same as the original order. | 2022021819071234 |
side | String | Yes | Order side. Must be the same as the original order. | BUY |
tif | String | Yes | Time-in-force: the validity period of the order. Reference OrderTIF. It must be the same as the original order. | DAY |
extended_hours_trading | Boolean | Yes | Extraded-hours trading. Must be the same as the original order. | false |
instrument_id | String | Yes | Unique identifier for the security. It must be the same as the original order. | 913256135 |
order_type | String | Yes | Order type . It must be the same as the original order. | MARKET |
limit_price | String | No | Limit price. Must be >0 Required for LIMIT / STOP_LOSS_LIMIT orders. It should not be passed for MARKET / STOP_LOSS / TRAILING_STOP_LOSS orders. | 100.49 |
qty | String | Yes | Order quantity. Must be a positive integer and the maximum value is 200000 shares. | 100 |
stop_price | String | No | Stop loss price. Must be >0 Required for STOP_LOSS / STOP_LOSS_LIMIT / TRAILING_STOP_LOSS orders.It should not be passed for LIMIT / MARKET orders. | 100.49 |
trailing_type | String | No | Trailing type Required for TRAILING_STOP_LOSS orders.It should not be passed for LIMIT / MARKET / STOP_LOSS / STOP_LOSS_LIMIT orders. | AMOUNT |
trailing_stop_step | String | No | The value of the spread for trailing stop orders. Required for TRAILING_STOP_LOSS orders.It should not be passed for LIMIT / MARKET / STOP_LOSS / STOP_LOSS_LIMIT orders. | 100.49 |
Response Parameter
Parameter | Type | Description | Example value |
---|---|---|---|
client_order_id | String | User-defined order ID | 2022021819071234 |
Request Example
Limit Order
- 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.US.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)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.us.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);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);
Market Order
- 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.US.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)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.us.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.setQty(qty);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);
Stop Order
- 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.US.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, stop_price=stop_price)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.us.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.setQty(qty);
stockOrder.setStopPrice(stopPrice);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);
Stop Limit Order
- 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.US.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)
if response.status_code == 200:
order_res = response.json()
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.us.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.setQty(qty);
stockOrder.setLimitPrice(limitPrice);
stockOrder.setStopPrice(stopPrice);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);
Trailing Stop Order
- 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.US.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, stop_price=stop_price, trailing_type=trailing_type,trailing_stop_step = 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.us.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.setQty(qty);
stockOrder.setStopPrice(stopPrice);
stockOrder.setTrailingType(trailingType);
stockOrder.setTrailingStopStep(trailingStopStep);
OrderResponse orderResponse = apiService.replaceOrder(accountId, stockOrder);