Skip to content

下单 ​

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_idstring是业务账户 ID。

请求参数 ​

参数类型位置必填说明
codestring请求体条件必填可交易标的代码。格式:market.symbol,例如 US.AAPL,US.AAPL250926C235000。普通订单必填;order_class 为 MLEG 时可不填,由 multi_leg_info.leg_infos 合成。
qtystring请求体是订单数量。期权和期货的单位为"合约"。
pricestring请求体否订单价格。期货账户精确到 9 位小数,外汇账户精确到 5 位小数,证券账户精确到 4 位小数,超出部分四舍五入。
sidetrd_side请求体是交易方向
order_typeorder_type请求体是订单类型
time_in_forcetime_in_force请求体是有效期
expire_timeuint64请求体条件必填微秒级 Unix 时间戳。当 time_in_force 为 GTD 时必填。
sessiontrading_session请求体否交易时段(仅适用于美股)。市价单仅支持 RTH。
aux_pricestring请求体否触发价格。当订单类型为 STOP、STOP_LIMIT、MARKET_IF_TOUCHED、LIMIT_IF_TOUCHED 时必填。期货账户精确到 9 位小数,外汇账户精确到 5 位小数,证券账户精确到 3 位小数,超出部分四舍五入。
trail_typetrail_type请求体否跟踪止损类型。仅跟踪止损单(TRAILING_STOP、TRAILING_STOP_LIMIT)可用。
trail_valuestring请求体否跟踪金额或比例。仅跟踪止损单可用。
trail_spreadstring请求体否指定价差。仅 TRAILING_STOP_LIMIT 可用。
lot_typelot_type请求体否手数类型,默认整手。适用于港股 / 日股交易。
remarkstring请求体否备注,UTF-8 编码后最大长度 64 字节。
order_classorder_class请求体否订单类别。多腿订单需指定为 MLEG。日本券商不支持组合期权。
multi_leg_infomulti_leg_info请求体否多腿订单信息,下多腿订单时必填。
sub_acc_idstring请求体条件必填日本账户必填。子账户 ID,由客户端从该账户的 sub_accounts[] 中选取(由「获取授权交易账户」接口返回)。非日本券商忽略。
position_idstring请求体条件必填外汇平仓(SELL / BUY_BACK)必填。其他市场可选:传入则平指定持仓,不传则按同标的持仓自动分配。
position_open_typeposition_open_type请求体否开仓类型,仅跟踪止损单(TRAILING_STOP、TRAILING_STOP_LIMIT)可用,控制是否允许开新仓
algo_infoalgo_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_LIMITTWAP 市价 / 限价algo_info.twap.participation_rate
VWAP / VWAP_LIMITVWAP 市价 / 限价algo_info.vwap.participation_rate
POV / POV_LIMITPOV 市价 / 限价(成交量占比)algo_info.pov.participation_rate
SLICER / SLICER_LIMITSlicer 市价 / 限价(切片)algo_info.slicer;slice_interval 与 display_qty 至少其一
PEG / PEG_LIMITPEG 市价 / 限价display_qty、peg_offset
ICEBERG_LIMIT冰山限价algo_info.iceberg.display_qty;非美股还需 start_time / end_time,美股可豁免

请求示例 ​

限价买入。以 150 美元买入 100 股 US.AAPL,当日有效。

bash
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。

bash
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 表示撤单前有效。

bash
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%。

bash
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"
  }' | jq

TWAP 限价算法单。必须带 algo_info,其中 start_time、end_time 必填且结束晚于开始,并带 twap.participation_rate。限价类同时带 price。

bash
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_idstring新建订单的订单 ID。

响应顶层还可能返回 need_order_confirm、confirm_id、jump_url,含义见下方示例与提示。

响应示例 ​

json
{
  "s": "ok",
  "d": {
    "order_id": "FH1D5B797DAC864000"
  }
}

失败响应:

业务错误:

json
{
  "s": "error",
  "errcode": 344,
  "errmsg": "Trading for this market not activated.",
  "need_order_confirm": false
}

需要二次确认:

json
{
  "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:

json
{
  "code": -12006,
  "trace_id": "385e116c10c8d386334acfc839f63251"
}