跳到主要内容

创建止盈止损

请求类型: POST 描述: /future/trade/v1/entrust/create-profit


限流规则

200/s/apikey


参数说明

名称类型必填默认值描述范围
symbolstringFALSEN/A交易对
origQtyintegerTRUE数量(张)
triggerProfitPriceintegerTRUE止盈触发价格
triggerStopPriceintegerTRUE止损触发价格
expireTimeintegerTRUE过期时间(timestamp)
positionSidestringTRUE持仓方向LONG; SHORT
profitDelegateOrderTypestringTRUE止盈委托订单类型LIMIT; MARKET
profitDelegateTimeInForcestringTRUE止盈委托订单有效期GTC; FOK; IOC; GTX
profitDelegatePricenumberFALSE止盈委托价格
stopDelegateOrderTypestringTRUE止损委托订单类型LIMIT; MARKET
stopDelegateTimeInForcestringTRUE止损委托订单有效期GTC; FOK; IOC; GTX
stopDelegatePricenumberFALSE止损委托价格

请求示例

curl -X POST "https://fapi.xt.com/future/trade/v1/entrust/create-profit" \
-H "validate-appkey: $APPKEY" # 必须
-H "validate-timestamp: $TIMESTAMP" # 必须
-H "validate-signature: $SIGNATURE" # 必须
-H "Content-Type: application/x-www-form-urlencoded" # 必须
-d "origQty=1" # 必须
-d "triggerProfitPrice=2000" # 必须
-d "triggerStopPrice=100" # 必须
-d "expireTime=1739558400000" # 必须(时间戳)
-d "positionSide=LONG" # 必须
-d "profitDelegateOrderType=LIMIT" # 必须
-d "profitDelegateTimeInForce=IOC" # 必须
-d "stopDelegateOrderType=LIMIT" # 必须
-d "stopDelegateTimeInForce=IOC" # 必须
-d "symbol=btc_usdt"

响应示例

{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}

错误码

错误码描述
invalid_time_in_force止盈止损时间设置失败
invalid_params参数设置有误或置空
invalid_quantity_scale数量须为正整数
invalid_trigger_profit_price止盈触发价格有误
invalid_trigger_stop_price止损触发价格有误
quantity_can_not_less_than下单数量小于最小限制
invalid_price价格设置有误
more_than_available超过了可提供的数量
trigger_profit_price_less_than_entry_price止盈价格必须高于开仓价(多)
trigger_profit_price_less_than_mark_price止盈价格必须高于当前标记价(多)
trigger_profit_price_less_than_index_price止盈价格必须高于当前指数价(多)
trigger_profit_price_more_than_entry_price止盈价格必须低于开仓价(空)
trigger_profit_price_more_than_mark_price止盈价格必须低于当前标记价(空)
trigger_profit_price_more_than_index_price止盈价格必须低于当前指数价(空)
trigger_stop_price_less_than_entry_price止损价格必须高于开仓价(空)
trigger_stop_price_less_than_mark_price止损价格必须高于当前标记价(空)
trigger_stop_price_less_than_index_price止损价格必须高于当前指数价(空)
trigger_stop_price_more_than_entry_price止损价格必须低于开仓价(多)
trigger_stop_price_more_than_mark_price止损价格必须低于当前标记价(多)
trigger_stop_price_more_than_index_price止损价格必须低于当前指数价(多)
user_can_not_trade账户禁止交易
sub_account_not_trade子账户禁止交易
user_can_not_open_position账户限制开仓
invalid_symbol不存在该交易对
symbol_is_not_trading交易对未在交易状态
symbol_is_not_open_position交易对未在开启状态
The trading pair currently does not support placing orders through the OpenAPI."该交易对当前不支持通过 OpenAPI 下单