创建订单
类型: POST
描述: /future/trade/v1/order/create
Content-Type =
application/x-www-form-urlencoded&&application/json
参数
| 名称 | 类型 | 必填 | 默认值 | 描述 | 范围 |
|---|---|---|---|---|---|
| clientOrderId | string | false | N/A | 客户订单 ID | |
| symbol | string | true | - | 交易对 | |
| orderSide | string | true | N/A | 订单方向 | BUY;SELL |
| orderType | string | true | N/A | 订单类型 | LIMIT;MARKET |
| origQty | number | true | N/A | 数量(张) | |
| price | number | false | N/A | 价格 | |
| timeInForce | string | false | GTC | 有效方式 | GTC;IOC;FOK;GTX |
| triggerProfitPrice | number | false | N/A | 止盈价格 | |
| triggerStopPrice | number | false | N/A | 止损价格 | |
| positionSide | string | true | N/A | 仓位方向 | LONG;SHORT |
限流规则
200/s/apikey
OrigQty 计算公式
公式
origQty = Truncate ((Balance * Percent * Leverage ) / (Mark_price * Contract_size))
解释
Truncate : 取整数部分
Balance : (walletBalance - openOrderMarginFrozen) , api: /future/user/v1/compat/balance/list
Percent : 用户输入 , 例如: 0.2
Leverage : 杠杆倍数 , 例如: 20
Mark_price : 市场标记价格 , 例如: 88888 (btc_usdt)
Contract_size : 合约面值 , api: /future/market/v1/public/symbol/detail , Contract multiplier(face value)
举例
truncate(10000 * 0.2 * 20 / 88888 / 0.0001) = 4500
请求示例
Request
REQUEST_BODY='{
"symbol":"eth_usdt",
"origQty":1,
"positionSide":"LONG",
"orderType":"LIMIT"
}'
# 该五个参数必须
curl -X POST "https://fapi.xt.com/future/trade/v1/order/create" -H "validate-appkey: $APPKEY" # 必须
-H "validate-timestamp: $TIMESTAMP" # 必须
-H "validate-singature: $SINGATURE" # 必须
-H "Content-Type: application/json" # 必须
-d "$REQUEST_BODY"
响应示例
Response
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
错误码
| 错误码 | 描述 |
|---|---|
| contract_not_open | 合约未开户 |
| exist_bonus_positon_not_create_reverse_position | 无法创建反向仓位 |
| account_error | 账户无体验金权限 |
| symbol_is_not_open_position | 交易对未开市 |
| invalid_params | 参数填写错误 |
| invalid_quantity_scale | origQty 必须是整数 |
| coupon_unavailable | 优惠券不可用 |
| welfare_coupon_not_exist | 优惠券不存在 |
| coupon_exceed_max_leverage | 优惠券超过最大杠杆 |
| exceed_max_leverage | 超过最大杠杆 |
| gateway_decommission_ip_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务,如有疑问,请联系客服 |
| gateway_decommission_kyc_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务,如有疑问,请联系客服 |
| GATEWAY_0003 | 当前用户触发风控,您的操作已被暂时禁止 |
| GATEWAY_0006 | 由于您触发风控规则,账户被锁定【{hour}小时{minutes}分钟】,如有疑问请联系客服或大客户经理 |
| GATEWAY_0007 | 由于您触发风控规则,账户被锁定【{minutes}分钟】,如有疑问请联系客服或大客户经理 |