下单
POST/api/v1.0/accounts/{acc_id}/orders提交新的交易订单。
下单结果怎么看
- 本接口需要 OAuth
trade:write。若返回权限不足,请确认 Token 的scope已包含该项,见 快速开始 · 权限范围。 s为ok:已受理,订单号在d.order_id。s为error且need_order_confirm为true:还需确认(不是最终失败),用顶层confirm_id调用二次确认。- 有
jump_url:请在浏览器打开该链接继续。 - 其他错误:按
errcode/errmsg处理。
need_order_confirm、confirm_id、jump_url 在响应顶层,不在 d 里。详见二次确认。
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
acc_id | string | 是 | 业务账户 ID。 |
请求参数
| 参数 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
code | string | 请求体 | 条件必填 | 可交易标的代码。格式:market.symbol,例如 US.AAPL,US.AAPL250926C235000。普通订单必填;order_class 为 MLEG 时可不填,由 multi_leg_info.leg_infos 合成。 |
qty | string | 请求体 | 是 | 订单数量。期权和期货的单位为"合约"。 |
price | string | 请求体 | 否 | 订单价格。期货账户精确到 9 位小数,外汇账户精确到 5 位小数,证券账户精确到 4 位小数,超出部分四舍五入。 |
side | trd_side | 请求体 | 是 | 交易方向 |
order_type | order_type | 请求体 | 是 | 订单类型 |
time_in_force | time_in_force | 请求体 | 是 | 有效期 |
expire_time | uint64 | 请求体 | 条件必填 | 微秒级 Unix 时间戳。当 time_in_force 为 GTD 时必填。 |
session | trading_session | 请求体 | 否 | 交易时段(仅适用于美股)。市价单仅支持 RTH。 |
aux_price | string | 请求体 | 否 | 触发价格。当订单类型为 STOP、STOP_LIMIT、MARKET_IF_TOUCHED、LIMIT_IF_TOUCHED 时必填。期货账户精确到 9 位小数,外汇账户精确到 5 位小数,证券账户精确到 3 位小数,超出部分四舍五入。 |
trail_type | trail_type | 请求体 | 否 | 跟踪止损类型。仅跟踪止损单(TRAILING_STOP、TRAILING_STOP_LIMIT)可用。 |
trail_value | string | 请求体 | 否 | 跟踪金额或比例。仅跟踪止损单可用。 |
trail_spread | string | 请求体 | 否 | 指定价差。仅 TRAILING_STOP_LIMIT 可用。 |
lot_type | lot_type | 请求体 | 否 | 手数类型,默认整手。适用于港股 / 日股交易。 |
remark | string | 请求体 | 否 | 备注,UTF-8 编码后最大长度 64 字节。 |
order_class | order_class | 请求体 | 否 | 订单类别。多腿订单需指定为 MLEG。日本券商不支持组合期权。 |
multi_leg_info | multi_leg_info | 请求体 | 否 | 多腿订单信息,下多腿订单时必填。 |
sub_acc_id | string | 请求体 | 条件必填 | 日本账户必填。子账户 ID,由客户端从该账户的 sub_accounts[] 中选取(由「获取授权交易账户」接口返回)。非日本券商忽略。 |
position_id | string | 请求体 | 条件必填 | 外汇平仓(SELL / BUY_BACK)必填。其他市场可选:传入则平指定持仓,不传则按同标的持仓自动分配。 |
position_open_type | position_open_type | 请求体 | 否 | 开仓类型,仅跟踪止损单(TRAILING_STOP、TRAILING_STOP_LIMIT)可用,控制是否允许开新仓 |
algo_info | algo_info | 请求体 | 否 | 算法单参数,当 order_type 为算法单类型时必填。结构同响应 algo_info,其中 twap/vwap/pov/slicer/peg/iceberg 子结构的字段为各算法类型专属必填项,参见 命名词典 |
支持的订单类型
本接口 order_type 以下列分类为准(完整取值见 命名词典 · order_type)。是否可下还取决于账户所属市场、标的和交易权限;不支持时接口会返回错误。
多腿组合期权用 order_class=MLEG + multi_leg_info 表达,不是新的 order_type。日本券商不支持组合期权。
常规
order_type | 含义 | 关键附加字段 |
|---|---|---|
LIMIT | 限价单 | 通常传 price |
MARKET | 市价单 | 一般不传 price;美股 session 仅支持 RTH |
AUCTION | 竞价市价单 | 多为港股竞价场景 |
AUCTION_LIMIT | 竞价限价单 | 同上,通常还传 price |
止损 / 触及
order_type | 含义 | 关键附加字段 |
|---|---|---|
STOP | 止损市价单 | 必填 aux_price |
STOP_LIMIT | 止损限价单 | 必填 aux_price,通常还有 price |
MARKET_IF_TOUCHED | 触及市价单 | 必填 aux_price |
LIMIT_IF_TOUCHED | 触及限价单 | 必填 aux_price,通常还有 price |
跟踪止损
order_type | 含义 | 关键附加字段 |
|---|---|---|
TRAILING_STOP | 跟踪止损市价单 | 必填 trail_type、trail_value;可选 position_open_type |
TRAILING_STOP_LIMIT | 跟踪止损限价单 | 上项 + 必填 trail_spread |
算法单
算法类 order_type 必须传 algo_info。各类型专属子结构见 命名词典 · algo_info。
order_type | 含义 | 专属约束(摘要) |
|---|---|---|
TWAP / TWAP_LIMIT | TWAP 市价 / 限价 | algo_info.twap.participation_rate |
VWAP / VWAP_LIMIT | VWAP 市价 / 限价 | algo_info.vwap.participation_rate |
POV / POV_LIMIT | POV 市价 / 限价(成交量占比) | algo_info.pov.participation_rate |
SLICER / SLICER_LIMIT | Slicer 市价 / 限价(切片) | algo_info.slicer;slice_interval 与 display_qty 至少其一 |
PEG / PEG_LIMIT | PEG 市价 / 限价 | display_qty、peg_offset |
ICEBERG_LIMIT | 冰山限价 | algo_info.iceberg.display_qty;非美股还需 start_time / end_time,美股可豁免 |
请求示例
限价买入。以 150 美元买入 100 股 US.AAPL,当日有效。
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "US.AAPL",
"qty": "100",
"price": "150.00",
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "DAY"
}' | jq市价卖出。卖出 100 股 HK.00700,当日有效。市价单不传 price。
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "HK.00700",
"qty": "100",
"side": "SELL",
"order_type": "MARKET",
"time_in_force": "DAY"
}' | jq止损限价。STOP_LIMIT 必须带触发价 aux_price,同时带上限价 price。GTC 表示撤单前有效。
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "US.NVDA",
"qty": "100",
"price": "999.00",
"aux_price": "1000.00",
"side": "SELL",
"order_type": "STOP_LIMIT",
"time_in_force": "GTC"
}' | jq跟踪止损限价。TRAILING_STOP_LIMIT 必须带 trail_type、trail_value 和 trail_spread。GTD 必须带晚于当前时间的微秒 expire_time。RATIO 时 trail_value 填 0.5 表示 0.5%。
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "US.NVDA",
"qty": "100",
"side": "SELL",
"order_type": "TRAILING_STOP_LIMIT",
"time_in_force": "GTD",
"expire_time": 1814313600000000,
"trail_type": "RATIO",
"trail_value": "0.5",
"trail_spread": "1.2"
}' | jqTWAP 限价算法单。必须带 algo_info,其中 start_time、end_time 必填且结束晚于开始,并带 twap.participation_rate。限价类同时带 price。
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "US.AAPL",
"qty": "100",
"side": "BUY",
"order_type": "TWAP_LIMIT",
"time_in_force": "DAY",
"price": "150.00",
"algo_info": {
"start_time": 1798761600000000,
"end_time": 1798765200000000,
"pricing_strategy": "ADAPTIVE",
"layering": "AUTO",
"twap": {
"participation_rate": "20"
}
}
}' | jq响应参数
| 字段 | 类型 | 说明 |
|---|---|---|
order_id | string | 新建订单的订单 ID。 |
响应顶层还可能返回
need_order_confirm、confirm_id、jump_url,含义见下方示例与提示。
响应示例
{
"s": "ok",
"d": {
"order_id": "FH1D5B797DAC864000"
}
}失败响应:
业务错误:
{
"s": "error",
"errcode": 344,
"errmsg": "Trading for this market not activated.",
"need_order_confirm": false
}需要二次确认:
{
"s": "error",
"errcode": 108330261,
"errmsg": "Due to liquidity and market conditions, you may be unable to open or close positions for this security. Do you want to continue?",
"need_order_confirm": true,
"confirm_id": "0a1984f400616ae1b2100008eb430000"
}鉴权失败。Access Token 无效时各接口都返回这段,字段是 code 和 trace_id,不是 s / errcode:
{
"code": -12006,
"trace_id": "385e116c10c8d386334acfc839f63251"
}