下单 (TRADE)
接口描述
下单
方式
order.place
请求
order.place
{
"id": "3f7df6e3-2df4-44b9-9919-d2f38f90a99a",
"method": "order.place",
"params": {
"apiKey": "HMOchcfii9ZRZnhjp2XjGXhsOBd6msAhKz9joQaWwZ7arcJTlD2hGPHQj1lGdTjR",
"positionSide": "BOTH",
"price": "43187.00",
"quantity": 0.1,
"side": "BUY",
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"timestamp": 1702555533821,
"type": "LIMIT",
"signature": "0f04368b2d22aafd0ggc8809ea34297eff602272917b5f01267db4efbc1c9422"
}
}
请求权重
0
请求参数
名称 | 类型 | 是否必需 | 描述 |
---|---|---|---|
symbol | STRING | YES | 交易对 |
side | ENUM | YES | 买卖方向 SELL , BUY |
positionSide | ENUM | NO | 持仓方向,单向持仓模式下非必填,默认且仅可填BOTH ;在双向持仓模式下必填,且仅可选择 LONG 或 SHORT |
type | ENUM | YES | 订单类型 LIMIT , MARKET , STOP , TAKE_PROFIT , STOP_MARKET , TAKE_PROFIT_MARKET , TRAILING_STOP_MARKET |
reduceOnly | STRING | NO | true , false ; 非双开模式下默认false ;双开模式下不接受此参数; 使用closePosition 不支持此参数。 |
quantity | DECIMAL | NO | 下单数量,使用closePosition 不支持此参数。 |
price | DECIMAL | NO | 委托价格 |
newClientOrderId | STRING | NO | 用户自定义的订单号,不可以重复出现在挂单中。如空缺系统会自动赋值。必须满足正则规则 ^[\.A-Z\:/a-z0-9_-]{1,36}$ |
stopPrice | DECIMAL | NO | 触发价, 仅 STOP , STOP_MARKET , TAKE_PROFIT , TAKE_PROFIT_MARKET 需要此参数 |
closePosition | STRING | NO | true , false ;触发后全部平仓,仅支持STOP_MARKET 和TAKE_PROFIT_MARKET ;不与quantity 合用;自带只平仓效果,不与reduceOnly 合用 |
activationPrice | DECIMAL | NO | 追踪止损激活价格,仅TRAILING_STOP_MARKET 需要此参数, 默认为下单当前市场价格(支持不同workingType ) |
callbackRate | DECIMAL | NO | 追踪止损回调比例,可取值范围[0.1, 5],其中 1代表1% ,仅TRAILING_STOP_MARKET 需要此参数 |
timeInForce | ENUM | NO | 有效方法 |
workingType | ENUM | NO | stopPrice 触发类型: MARK_PRICE (标记价格), CONTRACT_PRICE (合约最新价). 默认 CONTRACT_PRICE |
priceProtect | STRING | NO | 条件单触发保护:"TRUE","FALSE", 默认"FALSE". 仅 STOP , STOP_MARKET , TAKE_PROFIT , TAKE_PROFIT_MARKET 需要此参数 |
newOrderRespType | ENUM | NO | "ACK", "RESULT", 默认 "ACK" |
priceMatch | ENUM | NO | OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ;不能与price同时传 |
selfTradePreventionMode | ENUM | NO | NONE / EXPIRE_TAKER / EXPIRE_MAKER / EXPIRE_BOTH ; 默认NONE |
goodTillDate | LONG | NO | TIF为GTD时订单的自动取消时间, 当timeInforce 为GTD 时必传;传入的时间戳仅 保留秒级精度,毫秒级部分会被自动忽略,时间戳需大于当前时间+600s且小于253402300799000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
根据 order type
的不同,某些参数强制要求,具体如下:
Type | 强制要求的参数 |
---|---|
LIMIT | timeInForce , quantity , price 或priceMatch |
MARKET | quantity |
STOP , TAKE_PROFIT | quantity , stopPrice |
STOP_MARKET , TAKE_PROFIT_MARKET | stopPrice , price 或priceMatch |
TRAILING_STOP_MARKET | callbackRate |
条件单的触发必须:
- 如果订单参数
priceProtect
为true:
- 达到触发价时,
MARK_PRICE
(标记价格)与CONTRACT_PRICE
(合约最新价)之间的价差不能超过改symbol触发保护阈值- 触发保护阈值请参考接口
GET /fapi/v1/exchangeInfo
返回内容相应symbol中"triggerProtect"字段STOP
,STOP_MARKET
止损单:
- 买入: 最新合约价格/标记价格高于等于触发价
stopPrice
- 卖出: 最新合约价格/标记价格低于等于触发价
stopPrice
TAKE_PROFIT
,TAKE_PROFIT_MARKET
止盈单:
- 买入: 最新合约价格/标记价格低于等于触发价
stopPrice
- 卖出: 最新合约价格/标记价格高于等于触发价
stopPrice
TRAILING_STOP_MARKET
跟踪止损单:
- 买入: 当合约价格/标记价格区间最低价格低于激活价格
activationPrice
,且最新合约价格/标记价高于等于最低价设定回调幅度。- 卖出: 当合约价格/标记价格区间最高价格高于激活价格
activationPrice
,且最新合约价格/标记价低于等于最高价设定回调幅度。
TRAILING_STOP_MARKET
跟踪止损单如果遇到报错{"code": -2021, "msg": "Order would immediately trigger."}
表示订单不满足以下条件:
- 买入: 指定的
activationPrice
必须小于 latest price- 卖出: 指定的
activationPrice
必须大于 latest price
newOrderRespType
如果传RESULT
:
MARKET
订单将直接返回成交结果;- 配合使用特殊
timeInForce
的LIMIT
订单将直接返回成交或过期拒绝结果。
STOP_MARKET
,TAKE_PROFIT_MARKET
配合closePosition
=true
:
- 条件单触发依照上述条件单触发逻辑
- 条件触发后,平掉当时持有所有多头仓位(若为卖单)或当时持有所有空头仓位(若为买单)
- 不支持
quantity
参数- 自带只平仓属性,不支持
reduceOnly
参数- 双开模式下,
LONG
方向上不支持BUY
;SHORT
方向上不支持SELL
响应示例
{
"id": "3f7df6e3-2df4-44b9-9919-d2f38f90a99a",
"status": 200,
"result": {
"orderId": 325078477,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "iCXL1BywlBaf2sesNUrVl3",
"price": "43187.00",
"avgPrice": "0.00",
"origQty": "0.100",
"executedQty": "0.000",
"cumQty": "0.000",
"cumQuote": "0.00000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0.00",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE",
"selfTradePreventionMode": "NONE",
"goodTillDate": 0,
"updateTime": 1702555534435
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 300,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
}
]
}