持仓接口

 

仓位列表

GET /api/v1/perpetual/position/{contractCode}/list

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    

Response

[
  {
    "amount": "0",
    "base": "usdt",
    "baseDisplayName": "USDT",
    "bizType": "perpetual",
    "brokerId": 1,
    "closingAmount": "0",
    "contractCode": "btcusdt",
    "contractCodeDisplayName": "BTCUSDT",
    "createdDate": 1745993345000,
    "dealMarket": 0,
    "env": 0,
    "fee": "0",
    "gear": "",
    "id": 2916028,
    "indexBase": "btc",
    "indexBaseDisplayName": "BTC",
    "lever": "20",
    "liqudatePrice": "0.0",
    "liquidationDate": 1746676800000,
    "maintenanceMargin": "0.000000",
    "markPrice": "98363.9",
    "minQuoteDigit": 2,
    "minTradeDigit": 8,
    "openMargin": "0.000000",
    "orderAmount": "0",
    "preLiqudatePrice": "",
    "price": "0.0",
    "quote": "usdt",
    "quoteDisplayName": "USDT",
    "realizedSurplus": "0.000000",
    "score": "",
    "side": "long",
    "size": "0",
    "sort": 0,
    "traderUserName": "",
    "type": 0,
    "unRealizedSurplus": "0.000000"
  }
]

返回:

参数名称 是否必须 类型 描述 默认值 取值范围
id y long 持仓id    
amount y string 持仓数量    
base y string 基础货币,如usdt    
baseDisplayName y string 基础货币名,如USDT    
closingAmount y int 成交数量    
contractCode y string 合约    
contractCodeDisplayName y string 合约显示名    
createdDate y string 创建时间    
fee y string 手续费    
gear y string 风险限额    
id y long 仓位ID    
indexBase y string 指数货币    
indexBaseDisplayName y string 指数货币显示名    
lever y string 杠杆    
liqudatePrice y string 强平价    
liquidationDate y long 强平时间    
maintenanceMargin y string 维持保证金    
markPrice y string 标记价格    
minQuoteDigit y string 计价货币最小交易小数位    
minTradeDigit y string 基础货币最小交易小数位    
openMargin y string 开仓保证金    
price y string 成交均价    
quote y string 计价货币名,USD,CNY,USDT    
realizedSurplus y string 已实现盈亏    
side y string 仓位类型,long多,short空    
size y string 仓位价值    
type y string 0:全仓,1:逐仓    
sort y int 排序    
traderUserName y string 带单员昵称    
unRealizedSurplus y string 未实现盈亏    

|stopProfitAndLossOrders|止盈止损订单

参数名称 是否必须 类型 描述 默认值 取值范围
allType y string 0:部分 1:全部    
amount y string 数量    
avgPrice y string 平均成交价    
base y string 基础货币名,如btc、fbtc    
baseDisplayName y string 基础货币显示名,如BTC    
contractCode y string 是Base和Quote之间的组合 P_BTC_USDT,R_BTC_USDT    
contractCodeDisplayName y string 交易对的显示名称,如:BTCUSDT    
contractDirection y int 合约方向 0:正向,1:反向    
createdDate y string 创建时间    
dealAmount y string 已成交数量    
deductedFee y string 手续费减免    
dealMarket y int 0:普通单 1:带单 2:跟单    
detailSide y string 订单方向 1.开多open_long 2.开空open_short 3.平多close_long 4.平空close_short    
direction y string 条件单:触发方向,greater大于,less小于    
donationFee y string 赠金手续费    
donationOpenMargin y string 赠金开仓保证金    
donationProfit y string 赠金盈亏    
fee y string 该笔订单成交后交的手续费: 正表示得手续费,负表示付手续费    
growthType y string 持仓增长类型:1:开仓单 2:平仓单 0:无法确定    
guaranteedStopLossRate y string 保价止损费率    
guaranteedStopLossStatus y string 是否开启保价止损    
id y long 订单id    
indexBase y string 指数货币    
indexBaseDisplayName y string 指数货币显示名    
lever y string 杠杆    
liquidatePrice y string 强平价格    
liquidateDate y long 强平时间,时间戳    
marginDigit y int 标记价格小数位    
marketPriceDigit y int 标记价格小数位    
maxOrderAmount y int 每笔最大挂单张数    
merge y int 是否合并止盈止损 0:不合并 1:合并    
mergeId y int 合并ID    
minOrderAmount y int 每笔最小挂单张数    
maxOrderAmount y int 最大委托数量    
maxOrderAmount y int 最大委托数量    
mode y int 持仓模式 0:合仓 1:分仓    
modifyDate y int 修改时间    
mustMaker y long 被动委托:0:不care 1:只做maker,如何是taker就撤单    
orderDonationFee y string 赠金手续费    
orderFee y string 手续费    
orderPriceType y string 下单价格类型,对手价:opponent,最优20档:optimal_20,最优10档:optimal_10,最优5档:optimal_5    
orderSize y string 订单价值    
orderType y int 订单类型 0:普通单,1:止盈止损,2:计划委托    
positionId y long 仓位ID    
positionType y int 仓位类型    
price y string 委托价格    
principalFee y string 下单冻结的本金手续费    
principalOpenMargin y string 下单冻结的本金开仓保证金    
profit y string 该笔订单成交后对应的盈亏: 正表示盈利,负表示亏损    
quote y string 计价货币名,usd,cny,usdt    
quoteDisplayName y string 计价货币显示名    
reason y int 该笔订单取消的理由,0是默认值,没有理由    
reduceOnly y int 是否只减仓    
refConditionOrderId y long 条件单id    
refOrderCondition y object 条件单详情    
side y string 订单方向,long多,short空    
source y string 来源    
stopLimitType y string 止盈止损类型    
stopLoss n string 止损价格    
stopProfit n string 止盈价格    
systemType y int 10:限价 11:市价 13:强平单 14:爆仓单 15:穿仓 16:强减    
triggerBy y string 条件单触发类型,指数价格:index,标记价格:mark,最新价格:last    
triggerPrice y string 条件单触发价格    

 

 

 

 

 

 

 

获取所有仓位

GET /api/v1/perpetual/position/list-all

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
env n int 环境,默认0    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    

Response

[
    {
        "id": "1001",
        "amount": "4867",
        "base": "fbtc",
        "closingAmount": "0",
        "contractCode": "fbtcusd",
        "lever": "100",
        "liqudatePrice": "3237.43",
        "maintenanceMargin": "0.02527905",
        "markPrice": "9659.25",
        "minQuoteDigit": 2,
        "minTradeDigit": 8,
        "openMargin": "0.14863957",
        "price": "9626.54",
        "quote": "usd",
        "realizedSurplus": "0.00413503",
        "side": "long",
        "size": "5.05581019",
        "type": 0
    }
]

返回:

参数名称 是否必须 类型 描述 默认值 取值范围
id y long 持仓id    
amount y string 持仓数量    
base y string 基础货币名,如BTC、ETH    
closingAmount y int 成交数量    
contractCode y string 合约    
gear y string 风险限额    
lever y string 杠杆    
liqudatePrice y string 强平价    
maintenanceMargin y string 维持保证金    
markPrice y string 标记价格    
minQuoteDigit y string 计价货币最小交易小数位    
minTradeDigit y string 基础货币最小交易小数位    
openMargin y string 开仓保证金    
price y string 成交均价    
quote y string 计价货币名,USD,CNY,USDT    
realizedSurplus y string 已实现盈亏    
side y string 仓位类型,long多,short空    
size y string 仓位价值    
type y string 0:全仓,1:逐仓    

 

 

 

 

 

 

获取所有档位对应的保证金率和杠杆

GET /v1/perpetual/public/{contractCode}/lever-gears

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    

Response

{
    "code": 200,
    "data": [
        {
            "entryRate": "0.008",
            "gear": 1,
            "lever": "125",
            "maintainRate": "0.004",
            "maxOpenAmount": "100",
            "minOpenAmount": "0"
        }
    ],
    "msg": "success"
}

返回:

参数名称 是否必须 类型 描述 默认值 取值范围
entryRate y string 开仓保证金率    
gear y int 档位    
lever y string 杠杆    
maintainRate y string 维持保证金率    
maxOpenAmount y string 最大可开张数    
minOpenAmount y string 最小可开张数    

 

 

 

 

 

仓位和限额设置

GET /api/v1/perpetual/position/{contractCode}/configs

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    

Response

{
    "autoAddMargin": 0,
    "bizType": "perpetual",
    "brokerId": 1,
    "contractCode": "btcusdt",
    "contractCodeDisplayName": "BTCUSDT",
    "contractType": "perpetual",
    "deliverInterestRate": "0.000100",
    "env": 0,
    "feeRate": "0.0006",
    "fundRate": "0.0001",
    "indexPrice": "98594",
    "leverGears": [],
    "longDiffMarginRate": "0.03",
    "longLeverMaxOpenAmount": "150000",
    "longPositionConfigDetails": {
        "diffMarginRate": "0.03",
        "initOpenMarginRate": "0.05",
        "lever": "20",
        "maintainRate": "0.02",
        "maxOpenAmount": "150000",
        "side": "long",
        "userId": 0
    },
    "makerFeeRate": "0.0002",
    "markPrice": "98299.3",
    "onlyPositionConfigDetails": {
        "diffMarginRate": "0.03",
        "initOpenMarginRate": "0.05",
        "lever": "20",
        "maintainRate": "0.02",
        "maxOpenAmount": "150000",
        "side": "long",
        "userId": 0
    },
    "positionConfigDetails": [
        {
            "diffMarginRate": "0.03",
            "initOpenMarginRate": "0.05",
            "lever": "20",
            "maintainRate": "0.02",
            "maxOpenAmount": "150000",
            "side": "short",
            "userId": 0
        },
        {
            "diffMarginRate": "0.03",
            "initOpenMarginRate": "0.05",
            "lever": "20",
            "maintainRate": "0.02",
            "maxOpenAmount": "150000",
            "side": "long",
            "userId": 0
        }
    ],
    "selectedMode": 0,
    "separatePositionConfigDetails": [],
    "shortDiffMarginRate": "0.03",
    "shortLeverMaxOpenAmount": "150000",
    "shortPositionConfigDetails": {
        "diffMarginRate": "0.03",
        "initOpenMarginRate": "0.05",
        "lever": "20",
        "maintainRate": "0.02",
        "maxOpenAmount": "150000",
        "side": "short",
        "userId": 0
    },
    "sort": 1,
    "takerFeeRate": "0.0006",
    "type": 0,
    "unitAmount": "0.001",
    "userId": 109200034
}

返回:

main

参数名称 是否必须 类型 描述 默认值 取值范围
autoAddMargin y int 是否自动追加保证金    
contractCode y string 合约code    
contractCodeDisplayName y string 合约名称    
deliverInterestRate y string 交割费率    
feeRate y int 手续费率    
fundRate y string 资金费率    
indexPrice y string 指数价格    
longDiffMarginRate y string 做多差值保证金率    
longLeverMaxOpenAmount y string 多仓最大张数    
markPrice y string 标记价格    
selectedMode y int 选择的仓位模式    
shortDiffMarginRate y string 做空差值保证金率    
shortLeverMaxOpenAmount y string 空仓最大张数    
sort y int 排序    
type y int 0:全仓,1:逐仓    
unitAmount y string 张数:一张合约对应的quote面值    
makerFeeRate y string maker手续费率    
takerFeeRate y string taker手续费率    
userId y long 用户ID    
** longPositionConfigDetails   shortPositionConfigDetails 仓位详情**

参数名称|是否必须|类型| 描述 |默认值|取值范围 ————- | ————- | ————- |——–| ————- | ————- initOpenMarginRate|y|string| 初始保证金率 || diffMarginRate|y|string| 差值保证金率 || lever|y|string| 杠杆 || side|y|string| 方向 || maxOpenAmount|y|string| 最大可开张数 || lever|y|string| 杠杆 || maintainRate|y|string| 维持保证金率 ||  

设置杠杆

POST /api/v1/perpetual/position/{contractCode}/lever

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    
Body(json)
参数名称 是否必须 类型 描述 默认值 取值范围
type y int 杠杆类型   全仓:0,逐仓:1
lever y int 杠杆   1~125
side y string 方向   多仓:long,空仓:short

Response

{
    "code": 200,
    "data": {
        "selectedMode": 0,
        "shortLever": 20.0,
        "shortLeverMaxOpenAmount": "150000",
        "longLeverMaxOpenAmount": "8000",
        "longDiffMarginRate": "0.005",
        "type": 0,
        "shortDiffMarginRate": "0.02",
        "longLever": 100
    },
    "msg": "success"
}

返回:

参数名称 是否必须 类型 描述 默认值 取值范围
selectedMode y int 选择的持仓模式,0:合仓,1:分仓    
shortLever y int 做空杠杆    
shortLeverMaxOpenAmount y int 做空最大开仓数量    
longLeverMaxOpenAmount y int 做多最大开仓数量    
longDiffMarginRate y double 做多差值保证金率    
type y int 持仓模式    
shortDiffMarginRate y int 做空差值保证金率    
longLever y int 做空杠杆    

 

 

 

修改保证金

POST /api/v1/perpetual/position/{contractCode}/change-margin

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    
margin y string 保证金数量(正数表示添加保证金,负数表示减少保证金)    
side y string 方向   long 多仓 short 空仓
Body(json)
{
}

Response

{
    "code": 200,
    "data": null,
    "msg": "success"
}

返回:

参数名称 是否必须 类型 描述 默认值 取值范围
code y int 状态,200:成功    
msg y string 提示    
data y object      

设置自动追加保证金

POST /api/v1/perpetual/position/{contractCode}/setting

示例

请求参数:

路径参数
参数名称 是否必须 类型 描述 默认值 取值范围
contractCode y string 合约code    
Query
参数名称 是否必须 类型 描述 默认值 取值范围
AccessKeyId y string 访问key    
SignatureVersion y string 版本    
SignatureMethod y string 签名方法   HmacSHA256
Signature y string 签名    
Timestamp y string 时间戳    
value y string 1 开启自动追加;0-关闭自动追加    
Body(json)
{
}

返回:

{
    "code": 200,
    "data": null,
    "msg": "success"
}
参数名称 是否必须 类型 描述 默认值 取值范围
code y int 状态,200:成功    
msg y string 提示    
data y object