跳到主要内容

下单 (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

请求参数

名称类型是否必需描述
symbolSTRINGYES交易对
sideENUMYES买卖方向 SELL, BUY
positionSideENUMNO持仓方向,单向持仓模式下非必填,默认且仅可填BOTH;在双向持仓模式下必填,且仅可选择 LONGSHORT
typeENUMYES订单类型 LIMIT, MARKET, STOP, TAKE_PROFIT, STOP_MARKET, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET
reduceOnlySTRINGNOtrue, false; 非双开模式下默认false;双开模式下不接受此参数; 使用closePosition不支持此参数。
quantityDECIMALNO下单数量,使用closePosition不支持此参数。
priceDECIMALNO委托价格
newClientOrderIdSTRINGNO用户自定义的订单号,不可以重复出现在挂单中。如空缺系统会自动赋值。必须满足正则规则 ^[\.A-Z\:/a-z0-9_-]{1,36}$
stopPriceDECIMALNO触发价, 仅 STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET 需要此参数
closePositionSTRINGNOtrue, false;触发后全部平仓,仅支持STOP_MARKETTAKE_PROFIT_MARKET;不与quantity合用;自带只平仓效果,不与reduceOnly 合用
activationPriceDECIMALNO追踪止损激活价格,仅TRAILING_STOP_MARKET 需要此参数, 默认为下单当前市场价格(支持不同workingType)
callbackRateDECIMALNO追踪止损回调比例,可取值范围[0.1, 5],其中 1代表1% ,仅TRAILING_STOP_MARKET 需要此参数
timeInForceENUMNO有效方法
workingTypeENUMNOstopPrice 触发类型: MARK_PRICE(标记价格), CONTRACT_PRICE(合约最新价). 默认 CONTRACT_PRICE
priceProtectSTRINGNO条件单触发保护:"TRUE","FALSE", 默认"FALSE". 仅 STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET 需要此参数
newOrderRespTypeENUMNO"ACK", "RESULT", 默认 "ACK"
priceMatchENUMNOOPPONENT/ OPPONENT_5/ OPPONENT_10/ OPPONENT_20/QUEUE/ QUEUE_5/ QUEUE_10/ QUEUE_20;不能与price同时传
selfTradePreventionModeENUMNONONE / EXPIRE_TAKER/ EXPIRE_MAKER/ EXPIRE_BOTH; 默认NONE
goodTillDateLONGNOTIF为GTD时订单的自动取消时间, 当timeInforceGTD时必传;传入的时间戳仅保留秒级精度,毫秒级部分会被自动忽略,时间戳需大于当前时间+600s且小于253402300799000
recvWindowLONGNO
timestampLONGYES

根据 order type的不同,某些参数强制要求,具体如下:

Type强制要求的参数
LIMITtimeInForce, quantity, pricepriceMatch
MARKETquantity
STOP, TAKE_PROFITquantity, stopPrice
STOP_MARKET, TAKE_PROFIT_MARKETstopPrice, pricepriceMatch
TRAILING_STOP_MARKETcallbackRate
  • 条件单的触发必须:

    • 如果订单参数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 订单将直接返回成交结果;
    • 配合使用特殊 timeInForceLIMIT 订单将直接返回成交或过期拒绝结果。
  • 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
}
]
}