修改订单
接口说明
功能说明:修改订单。
注意事项:修改订单前必须已经成功调用了下单接口。
适用对象:通过OpenAPI开发平台对接webull的客户。
请求URL:/trade/order/replace
请求方式:POST
频次限制:每个App ID调用频次限制为1秒1次。
请求参数
注:只允许修改数量和价格(不需修改的数量与价格字段则传原值),其他参数需与原订单相同,需传但不能改
参数 | 类型 | 是否必填 | 描述 | 示例值 |
---|---|---|---|---|
account_id | String | 是 | 账户id | 20150320010101001 |
stock_order | {}stock_order | 是 | 股票下单参数 | 见示例代码 |
stock_order:
参数 | 类型 | 是否必填 | 描述 | 示例值 |
---|---|---|---|---|
client_order_id | String | 是 | 自定义订单ID,必须与原订单值相同 | 2022021819071234 |
side | String | 是 | 买卖方向,必须与原订单值相同 | BUY |
tif | String | 是 | 订单有效期,必须与原订单值相同 | DAY |
extended_hours_trading | Boolean | 是 | 是否允许盘前盘后交易,必须与原订单值相同 | false |
instrument_id | String | 是 | 资产标的ID,必须与原订单值相同 | 913256135 |
order_type | String | 是 | 订单类型 ,必须与原订单值相同 | MARKET |
limit_price | String | 否 | 限价价格,必须>0LIMIT / STOP_LOSS_LIMIT 必填MARKET / STOP_LOSS / TRAILING_STOP_LOSS 不能填值 | 100.49 |
qty | String | 是 | 下单数量,必须为正整数,最大值为200000股 | 100 |
stop_price | String | 否 | 止损价格,必须>0STOP_LOSS / STOP_LOSS_LIMIT / TRAILING_STOP_LOSS 必填LIMIT / MARKET 不能填值 | 100.49 |
trailing_type | String | 否 | 追踪类型TRAILING_STOP_LOSS 必填LIMIT / MARKET / STOP_LOSS / STOP_LOSS_LIMIT 不能填值 | AMOUNT |
trailing_stop_step | String | 否 | 跟踪止损单的价差数值TRAILING_STOP_LOSS 必填LIMIT / MARKET / STOP_LOSS / STOP_LOSS_LIMIT 不能填值 | 100.49 |
响应参数
参数 | 类型 | 描述 | 示例值 |
---|---|---|---|
client_order_id | String | 第三方订单ID | 2022021819071234 |
请求示例
限价单
- 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);
市价单
- 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);
止损单
- 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);
止损限价单
- 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);
跟踪止损单
- 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);
响应示例
{
"code": 200,
"msg": "ok",
"data": {
"client_order_id": "01916462123512190"
}
}
异常示例
{
"error_code": "TRADE_WEBULL_REQUEST_PROCESSING",
"message": "The order is processing, please try later"
}