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

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

stock_order:

ParameterTypeRequired fieldsDescriptionExample value
client_order_idStringYesClient order ID. Must be the same as the original order.2022021819071234
sideStringYesOrder side. Must be the same as the original order.BUY
tifStringYesTime-in-force: the validity period of the order. Reference OrderTIF. It must be the same as the original order.DAY
extended_hours_tradingBooleanYesExtraded-hours trading. Must be the same as the original order.false
instrument_idStringYesUnique identifier for the security. It must be the same as the original order.913256135
order_typeStringYesOrder type . It must be the same as the original order.MARKET
limit_priceStringNoLimit 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
qtyStringYesOrder quantity. Must be a positive integer and the maximum value is 200000 shares.100
stop_priceStringNoStop 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_typeStringNoTrailing type

Required for TRAILING_STOP_LOSS orders.
It should not be passed for LIMIT / MARKET / STOP_LOSS / STOP_LOSS_LIMIT orders.
AMOUNT
trailing_stop_stepStringNoThe 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

ParameterTypeDescriptionExample value
client_order_idStringUser-defined order ID2022021819071234

Request Example

Limit Order

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

Market Order

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

Stop Order

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

Stop Limit Order

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

Trailing Stop Order

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

Response Example

Exception Example