下单
接口说明
功能说明:该接口供美国客户调用下单,仅支持下美国市场的股票和ETF订单。
适用对象:通过OpenAPI开发平台对接webull的客户。
请求URL:/trade/order/place
请求方式:POST
频次限制:每个App ID调用频次限制为1秒1次。
请求参数
参数 | 类型 | 是否必填 | 描述 | 示例值 |
---|---|---|---|---|
account_id | String | 是 | 账户id | 20150320010101001 |
stock_order | {}stock_order | 是 | 股票下单参数 | 见示例代码 |
stock_order:
参数 | 类型 | 是否必填 | 描述 | 示例值 |
---|---|---|---|---|
client_order_id | String | 是 | 自定义订单ID,必须与原订单值相同。 | 27290e2404e84572b2ffa0f89906525d |
side | String | 是 | 买卖方向 | BUY |
tif | String | 是 | 订单有效期 | DAY |
extended_hours_trading | Boolean | 是 | 是否允许盘前盘后交易 可选值: true - 允许盘前盘后交易(只支持订单类型为 LIMIT 时传true)false - 不允许盘前盘后交易 | 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 |
请求示例
注释:
- 数量:如果价格在$0.01和$0.099之间,最低股数为1000股。 如果价格在 0.1 美元到 1 美元之间,最低股数为 100 股。 如果价格大于 1 美元,最低为 1 股。 价格低于$0.01只支持平仓,不能建仓。
- 价格:如果价格大于1美元,最小步长为0.01。 如果小于 1 美元,则最小步长为 0.0001。
限价单
注释:
限价:如果限价大于1美元,则最小步长为0.01。 如果小于 1 美元,则最小步长为 0.0001。
- 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.place_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.placeOrder(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.place_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.placeOrder(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.place_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.placeOrder(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.place_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.placeOrder(accountId, stockOrder);
跟踪止损单
注释:
- 百分比:百分比默认步长为1% ,传入 20 实际对应 20%; 当跟踪类型为比例时,数值 >= 1% , 且是整数;
- 价差小数点位数:(当trailing_type为AMOUNT时)跟踪价差>=$1,最小调整步长为0.01; 跟踪价差<$1,最小调整步长为0.0001。
- 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.place_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.placeOrder(accountId, stockOrder);
响应示例
{
"code": 200,
"msg": "ok",
"data": {
"client_order_id": "01916462123512190"
}
}
异常示例
{
"error_code": "TRADE_PLACE_ORDER_REPEAT",
"message": "The order existed"
}