HTTP
鉴权过程如下
-
http报文的输入的参数字符串如下:
market=BTCUSD&type=buy&price=680&amount=1.0×tamp=1550743431000
-
在上面最后拼接
secret_key
得到如下:
market=BTCUSD&type=buy&price=680&amount=1.0×tamp=1550743431000&secret_key=B51068CF10B34E7789C374AB932696A05E0A629BE7BFC62F
备注:发送http报文体不需要带上secret_key
参数,该步骤只是为了计算sha256
签名。 -
对上面字符串进行
sha256
即签名,转换为16进制小写
,长度为64位
,再把这个签名加入到http的头中如下:
Authorization: a174066d9ccbeb33803c2a84e20792d31bed5a6e3da8fca23e38fc8dbb917a13
-
在http的头中增加
AccessId
,服务端根据AccessId
寻找对应的用户信息
AccessId: 4DA36FFC61334695A66F8D29020EB589
-
服务端收到http报文后,根据
AccessId
找到用户的secret key
,进行上面同样的操作,判断收到的签名与自己计算的签名是否相等,如果相等则鉴权成功,否则失败。 -
查看签名生成Demo
服务器收到请求时会判断请求中的时间戳timestamp,如果是5000毫秒之前发出的,则请求会被认为无效。这个时间窗口值可以通过发送可选参数recvWindow来自定义。
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- GET类请求
GET请求示例
http://api.coinex.com/perpetual/v1/market/depth?market=BTCUSD&merge=1
- POST类请求
POST请求示例
http://api.coinex.com/perpetual/v1/order/put_limit
请求参数以application/x-www-form-urlencoded的方式放入http body中
- RESPONSE
RESPONSE示例
// success
{
"message": "OK",
"data": {
....
},
"code": 0
}
// error
{
"message": "error message",
"data": {},
"code": 11
}
- 错误码描述
错误码 | 错误信息 | 描述 |
---|---|---|
3001 | invalid argument | 参数错误 |
3002 | service unavailable | 服务不可用 |
3003 | service timeout | 服务繁忙 |
3004 | method not found | 方法不存在 |
3005 | require auth | 用户身份验证失败 |
3006 | internal error | 内部错误 |
3007 | Service is not available during funding fee settlement. Please try again later. | 收取资金费用期间服务不可用 |
3008 | service too busy | 服务繁忙 |
3101 | market not exists | 市场不存在 |
3102 | user id not exists | 用户不存在 |
3103 | order not exists | 订单不存在 |
3104 | stop price equal to deal price | 止损、止盈或计划委托单价格等于成交价 |
3105 | position not exists | 仓位不存在 |
3106 | asset not exists | 资产不存在 |
3107 | balance update repeated | 余额更新重复 |
3108 | amount exceed limit | 数量超过仓位档位限制 |
3109 | balance not enough | 余额不足 |
3110 | trader not enough | 交易对手不足 |
3111 | exceed max limit | limit值超出最大限制 |
3112 | user not match | 用户不匹配 |
3113 | invalid leverage value | 无效的杠杆值 |
3115 | position liquidating | 仓位正在强平中 |
3116 | can not complete deal, kill order | 无法全部成交,终止订单 |
3117 | position will liquidation | 该操作将导致仓位强平 |
3118 | limit price lower than liquidation price | 限价低于强平价 |
3119 | limit price higher than liquidation price | 限价高于强平价 |
3120 | no position | 仓位不存在 |
3121 | cross position | 全仓不能调整保证金 |
3122 | order exist | 订单已存在 |
3123 | margin less init margin | 保证金不能少于起始保证金 |
3124 | sub too much margin | 提取的保证金过多 |
3125 | stop price equal to index price | 止损、止盈或计划委托单价格等于指标价 |
3126 | stop price equal to sign price | 止损、止盈或计划委托单价格等于标记价 |
3127 | amount too small | 数量太少 |
3128 | invalid price size | 无效的价格粒度 |
3129 | not only maker, kill order | 无法只下maker,终止订单 |
3130 | trading is unavailable in this market | 该市场目前禁止交易 |
3131 | Stop order amount limit exceeded 100 orders at most for one market | 单个市场允许的计划委托单数量不得超过100 |
3132 | position is closing | 用户其他的平仓策略正在执行,比如一键平仓、止盈止损等平仓策略 |
3133 | Stop-Loss price cannot be lower than the forced liquidation price | 多仓止损价格不能低于强平价格 |
3134 | Stop-Loss price cannot be higher than the current price | 空仓止损价格不能高于当前价格 |
3135 | Take-Profit price cannot be lower than the current price | 多仓止盈价格不能低于当前价格 |
3136 | invalid close amount | 无效的平仓数量 |
3137 | Take-Profit price cannot be higher than the current price | 空仓止盈价格不能高于当前价格 |
3138 | Stop-Loss price cannot be higher than the forced liquidation price | 空仓止损价格不能高于强平价格 |
3139 | Stop-Loss price cannot be lower than the current price | 多仓止损价格不能低于当前价格 |
4001 | service unavailable | 服务不可用 |
4002 | service timeout | 服务超时 |
4003 | internal error | 内部错误 |
4004 | invalid argument | 无效参数 |
4005 | access_id not exists | AccessId不存在 |
4006 | authorization fail | 授权失败 |
4007 | ip not allow visit | ip不允许访问 |
4008 | need authorization header | HTTP头中需要添加授权信息 |
4009 | unknown method | 无效的方法 |
4010 | time check error | 时间检查错误 |
4011 | user is forbid | 用户被禁止 |
4012 | The deviation between your estimated execution price and the index price is greater than 10%, you can reduce your delegation amount appropriately and try again. | 您预估的执行价与指标价之间偏差大于10%,您可以适当调价格并重试 |
4013 | The deviation between your delegated price and the index price is greater than x%, you can appropriately adjust your delegation price and try again | 您的委托价格与指数价格之间的偏差大于x%,您可以适当调整您的委托价格并重试 注:BTCUSD、BTCUSDT、ETHUSD、ETHUSDT为5%,其他合约市场为10% |
4014 | The deviation between your delegated price and the trigger price is greater than x%, you can appropriately adjust your delegated price and try again | 您的委托价格与触发价格之间的偏差大于x%,您可以适当调整您的委托价格并重试 注:BTCUSD、BTCUSDT、ETHUSD、ETHUSDT为5%,其他合约市场为10% |
4015 | The current market depth is low, please reduce your selling amount appropriately and try again. | 当前市场深度较低,请适当减少卖出量,然后重试 |
4016 | read only | 仅可读 |
示例
// Request
timestamp=1513746038205
// Response
{
"code": 0,
"data": "pong",
"message": "OK"
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/ping
- 请求参数描述: none
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
data | String | “pong” |
示例
// Request
timestamp=1513746038205
// Response
{
"code": 0,
"data": 1513746038205,
"message": "OK"
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/time
- 请求参数描述: none
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
data | Integer | 服务器时间, 毫秒 |
示例
// Request
timestamp=1513746038205
// Response
"data": [
{
"name": "BTCUSD",
"type": 2,
"stock": "BTC",
"money": "USD",
"fee_prec": 4,
"stock_prec": 8,
"money_prec": 8,
"multiplier": 1,
"amount_prec": 0,
"amount_min": "10",
"tick_size": "0.5",
"leverages": ["3", "5", "8", "10", "15", "20", "30", "50", "100"],
"available": true,
"funding": {
"interval": 28800,
"min": 0.00375,
"max": -0.00375
}
},
...
]
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/list
- 请求参数描述: none
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
name | String | 市场名称 |
type | Integer | 合约类型, 1: 正向合约, 2: 反向合约 |
stock | String | 基准币 |
money | String | 标价币 |
fee_prec | Integer | 费率精度 |
stock_prec | Integer | 基准币精度 |
money_prec | Integer | 标价币精度 |
multiplier | Integer | 乘数 |
amount_prec | Integer | 数量精度 |
amount_min | String | 最小数量 |
tick_size | String | 价格粒度 |
leverages | Array<String> | 杠杆列表 |
available | Bool | 市场是否开放 |
funding | Object | 资金费率 |
>interval | Integer | 资金费率收取周期秒数 |
>min | String | 资金费率最大值 |
>max | String | 资金费率最小值 |
示例
// Request
timestamp=1513746038205
// Response
"data": {
"BTCUSD": [
["1000", "100", "0.005"],
["10000", "50", "0.01"],
["15000", "30", "0.015"],
["25000", "20", "0.02"],
["50000", "15", "0.025"],
["75000", "10", "0.03"],
["80000", "6", "0.035"],
["110000", "6", "0.04"],
["120000", "5", "0.045"],
["130000", "5", "0.05"],
["140000", "5", "0.055"],
["150000", "3", "0.06"]
]
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/limit_config
- 请求参数描述: none
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
params[0] | String | amount, 数量 |
params[1] | String | leverage, 杠杆 |
params[2] | String | mainten margin, 维持保证金率 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
// Response
"data": {
"date": 1640165898905,
"ticker": {
"vol": "2374.8320",
"low": "48300.07",
"open": "48589.34",
"high": "49588.57",
"last": "49005.74",
"buy": "49002.74",
"period": 86400,
"funding_time": 381,
"position_amount": "179.5737",
"funding_rate_last": "-0.00007488",
"funding_rate_next": "-0.00027732",
"funding_rate_predict": "-0.00043509",
"insurance": "10647261.12543132884543148442",
"sign_price": "48999.27",
"index_price": "49010.06000000",
"sell_total": "17.5542",
"buy_total": "11.3251",
"buy_amount": "0.0510",
"sell": "49004.85",
"sell_amount": "1.5010"
}
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/ticker
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
period | Integer | 周期 |
funding_time | Integer | 下次收取资金费率剩余时间, 单位:分钟 |
position_amount | String | 仓位数量 |
funding_rate_last | String | 上次资金费率 |
funding_rate_next | String | 下次资金费率 |
funding_rate_predict | String | 资金费率预测 |
last | String | 最新价格 |
sign_price | String | 标记价 |
index_price | String | 指标价 |
sell_total | String | 最近1000笔成交中的卖单数量 |
buy_total | String | 最近1000笔成交中的买单数量 |
open | String | 开盘价 |
close | String | 收盘价 |
high | String | 最高价 |
low | String | 最低价 |
vol | String | 数量 |
buy | String | 买一价 |
buy_amount | String | 买一量 |
sell | String | 卖一价 |
sell_amount | String | 卖一量 |
date | Integer | 日期时间戳 |
示例
// Request
timestamp=1513746038205
// Response
"data": {
"ticker":{
"BTCUSD": {
"vol": "2374.8320",
"low": "48300.07",
"open": "48589.34",
"high": "49588.57",
"last": "49005.74",
"buy": "49002.74",
"period": 86400,
"funding_time": 381,
"position_amount": "179.5737",
"funding_rate_last": "-0.00007488",
"funding_rate_next": "-0.00027732",
"funding_rate_predict": "-0.00043509",
"insurance": "10647261.12543132884543148442",
"sign_price": "48999.27",
"index_price": "49010.06000000",
"sell_total": "17.5542",
"buy_total": "11.3251",
"buy_amount": "0.0510",
"sell": "49004.85",
"sell_amount": "1.5010"
}
...
},
"date": 1640165898905
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/ticker/all
- 请求参数描述: none
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
period | Integer | 周期 |
funding_time | Integer | 下次收取资金费率剩余时间, 单位:分钟 |
position_amount | String | 仓位数量 |
funding_rate_last | String | 最新资金费率 |
funding_rate_next | String | 下次资金费率 |
funding_rate_predict | String | 资金费率预测 |
last | String | 最新价格 |
sign_price | String | 标记价 |
index_price | String | 指标价 |
sell_total | String | 最近1000笔成交中的卖单数量 |
buy_total | String | 最近1000笔成交中的买单数量 |
open | String | 开盘价 |
close | String | 收盘价 |
high | String | 最高价 |
low | String | 最低价 |
vol | String | 数量 |
buy | String | 买一价 |
buy_amount | String | 买一量 |
sell | String | 卖一价 |
sell_amount | String | 卖一量 |
date | Integer | 日期时间戳 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&merge=0.01
&limit=1
// Response
"data": {
"asks": [
["48969.85", "0.0005"],
["48974.84", "0.0146"],
...
],
"bids": [
["48969.84", "3.4175"],
["48969.83", "0.0025"],
...
],
"last": "48969.85",
"sign_price": "48966.61",
"index_price": "48977.08"
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/depth
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称,例如:“BTCUSD”合约市场 |
merge | String | Y | 精度合并,取值为:[“10”, “1”, “0”, “0.1”, “0.01”]中的其中一个 |
limit | Integer | Y | 获取的条数,取值为:[5, 10, 20, 50]中的其中一个 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
asks[0][0] | String | 卖一价 |
asks[0][1] | String | 卖一量 |
bids[0][0] | String | 买一价 |
bids[0][1] | String | 买一量 |
last | String | 最新价 |
sign_price | String | 标记价 |
index_price | String | 指标价 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&last_id=0
&limit=1
// Response
"data": [
{
"id": 227979125,
"type": "sell",
"price": "48926.49",
"amount": "0.0264",
"date": 1640166869,
"date_ms": 1640166869509
}
...
]
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/deals
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
last_id | Integer | N | 上次返回结果的最大ID |
limit | Integer | N | 获取的数量 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
id | Integer | 成交id |
type | String | 类型, “buy”: 买, “sell”: 卖 |
price | String | 成交价格 |
amount | String | 成交数量 |
date | String | 成交时间, 单位: 秒 |
date_ms | String | 成交时间, 单位: 毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&type=1day
&limit=1
// Response
"data": [
[
1440308700,
"233.37",
"233.48",
"243.37",
"223.48",
"52.01",
"12284.48"
],
...
]
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/kline
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场市场 |
limit | Integer | N | 获取K线数量,不能超过1000,默认为1000 |
type | String | Y | K线信息类别,支持如下参数,1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, 1day, 3day, 1week |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
data[0][0] | Integer | 时间戳 |
data[0][1] | String | 开盘价 |
data[0][2] | String | 收盘价 |
data[0][3] | String | 最高价 |
data[0][4] | String | 最低价 |
data[0][5] | String | 数量 |
data[0][6] | String | 交易额 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"offset": 10,
"limit": 100,
"records": [
{
"id": 1,
"time": 102001.123,
"deal_type": 1,
"market": "BTCUSD",
"user_id": 11,
"deal_user_id": 11,
"order_id": 13,
"deal_order_id": 13,
"position_id": 12,
"side": 1,
"role": 1,
"position_type": 1,
"price": "110.1",
"open_price": "120.1",
"settle_price": "120.1",
"amount": "110",
"position_amount": "220",
"margin_amount": "220",
"leverage": "10",
"deal_stock": "0.222",
"deal_fee": "0.001",
"deal_margin": "20",
"fee_rate": "0.02",
"deal_profit": "100",
"deal_insurance": "0.004",
"fee_asset": "CET",
"fee_discount": "0.03",
"fee_price": "0.1"
}
...
]
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/market/user_deals
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 0 不限制, 1 卖, 2 买 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的数量 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
offset | Integer | 偏移量 |
limit | Integer | 获取的数量 |
id | Integer | 交易id |
time | Integer | 时间戳 |
deal_type | Integer | 交易类型, 1: 开仓, 2: 加仓, 3: 减仓, 4: 平仓, 5: 系统减仓, 6: 仓位强平, 7: 仓位adl |
market | String | 市场名称 |
user_id | Integer | 用户id |
deal_user_id | Integer | 对手用户id |
order_id | Integer | 订单id |
deal_order_id | Integer | 对手订单id |
position_id | Integer | 仓位id |
side | Integer | 1: 卖, 2: 买 |
role | Integer | 1: maker, 2: taker |
position_type | Integer | 仓位类型, 1: 逐仓, 2: 全仓 |
price | String | 价格 |
open_price | String | 开仓价格 |
settle_price | String | 结算价格 |
amount | String | 数量 |
position_amount | String | 仓位数量 |
margin_amount | String | 成交后的仓位保证金 |
leverage | String | 杠杆 |
deal_stock | String | 基准币交易数量 |
deal_fee | String | 手续费 |
deal_margin | String | 交易的保证金 |
fee_rate | String | 手续费费率 |
deal_profit | String | 已实现收益 |
deal_insurance | String | 消耗或增加的保险基金 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&leverage=10
&position_type=1
// Response
"data": {
"position_type": 1,
"leverage": "10"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/market/adjust_leverage
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
leverage | String | Y | 杠杆 |
position_type | Integer | Y | 1 逐仓 2 全仓 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_type | Integer | 仓位类型 |
leverage | String | 杠杆 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&price=1100
&side=2
// Response
"data": {
"position_expect": "10"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/market/position_expect
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
price | String | Y | 价格 |
side | Integer | Y | 1: 卖 2: 买 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_expect | String | 预计可开仓位数 |
示例
// Request
timestamp=1513746038205
// Response
"data": {
"BTC": {
"available": "250",
"frozen": "10",
"tranfer": "10",
"balance_total": "11",
"margin", "10",
"profit_unreal": "100"
},
"ETH": {
"available": "250",
"frozen": "10",
"tranfer": "10",
"balance_total": "11",
"margin", "10",
"profit_unreal": "100"
}
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/asset/query
- 请求参数描述: None
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
available | String | 可用余额 |
frozen | String | 冻结 |
tranfer | String | 可转 |
balance_total | String | 账户余额 |
margin | String | 保证金 |
profit_unreal | String | 未实现盈亏 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=2
&amount=1
&price=1100
&effect_type=1
&option=0
&client_id=client1
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/put_limit
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 委托类型, 1: 表示卖空,2: 表示买多 |
amount | String | Y | 委托数量 |
price | String | Y | 委托价格 |
effect_type | Integer | N | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
option | Integer | N | 选项, 1: 只下maker单, 2: 隐藏委托, 3: 只下maker单并隐藏委托。默认为0 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,1: 一直有效直至取消, 2: 立刻成交或取消, 3: 完全成交或取消 |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=2
&amount=1
&client_id=client1
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/put_market
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 委托类型, 1: 表示卖空,2: 表示买多 |
amount | String | Y | 委托数量 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=2
&stop_type=1
&amount=1
&price=1100
&stop_price=1000
&effect_type=1
&option=0
&client_id=client1
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/put_stop_limit
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 委托类型 1表示卖空,2表示买多 |
stop_type | Integer | Y | 触发类型 1: 最新成交价格触发,2: 指数价格触发,3: 标记价格触发 |
amount | String | Y | 委托数量 |
stop_price | String | Y | 触发价格 |
price | String | Y | 委托价格 |
effect_type | Integer | N | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
option | Integer | N | 选项, 1: 只下maker单, 2: 隐藏委托, 3: 只下maker单并隐藏委托。默认为0 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=2
&stop_type=1
&amount=1
&stop_price=1000
&client_id=client1
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/put_stop_market
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 委托类型, 1: 表示卖空,2: 表示买多 |
stop_type | Integer | Y | 触发类型, 1: 最新成交价格触发,2: 指数价格触发,3: 标记价格触发 |
amount | String | Y | 委托数量 |
stop_price | String | Y | 触发价格 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_ids=39950p39950
// Response
"data": [
{
"code": 0,
"message": "",
"order": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0",
"deal_asset_fee": "0",
"leverage": "10",
"position_type": 1
}
},
{
// order detail
},
{
// ...
}
]
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel_batch
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_ids | String | Y | 未完成订单ID列表,多个ID之间使用”p”进行分割 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
code | Integer | 错误码 |
message | String | 错误信息 |
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 未完成订单ID |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel_all
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | N | 0: 所有, 1: 卖, 2: 买 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
// Response
"data": {
"order_id": 10,
"market": "BTCUSD",
"type": 1,
"side": 2,
"effect_type": 1,
"stop_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "web",
"state": 1,
"stop_price": "9200",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"client_id": ""
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel_stop
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 未完成订单ID |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,1: 一直有效直至取消, 2: 立刻成交或取消, 3: 完全成交或取消 |
stop_type | Integer | 触发方式 1: 最新成交价, 2: 指数价, 3: 标记价格 |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
stop_price | String | 触发价格 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
client_id | String | 客户端id |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel_stop_all
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | N | 0: 所有, 1: 卖, 2: 买 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
&client_id=client1
&offset=0
&limit=1
// Response
"data": {
"records": [
{
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
},
...
],
"total": 10,
"offset": 0,
"limit": 10
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/pending
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | N | 市场名称 |
side | Integer | Y | 0: 全部, 1: 卖, 2: 买 |
client_id | String | N | client_id是订单的自定义ID。可批量查询使用同一client_id的订单。 |
offset | Integer | Y | 偏移量,即从哪条开始获取 |
limit | Integer | Y | 一次获取记录数,默认为20条,最大为100条 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
total | Integer | 总记录数 |
offset | Integer | 偏移量 |
limit | Integer | 一次获取的记录数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1,
"status": "not_deal"
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/status
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 订单id |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
status | String | 状态 not_deal: 未执行, part_deal: 部分执行, done: 已执行, cancel: 已取消 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
&client_id=client1
&offset=0
&limit=1
// Response
"data": {
"records": [
{
"order_id": 10,
"market": "BTCUSD",
"type": 1,
"side": 2,
"effect_type": 1,
"stop_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "web",
"state": 1,
"stop_price": "9200",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"client_id": ""
},
...
],
"total": 10,
"offset": 10,
"limit": 5
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/stop_pending
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 0:全部 1:卖, 2: 买 |
client_id | String | N | client_id是订单的自定义ID。可批量查询使用同一client_id的订单。 |
offset | Integer | Y | 偏移量,即从哪条开始获取 |
limit | Integer | Y | 获取的条数,默认为20条,最大为100条 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
stop_type | Integer | 触发方式 1: 最新成交价, 2: 指数价, 3: 标记价格 |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
state | Integer | 计划单触发价与当前市场价的关系 1:低于当前市场价 2:高于当前市场价 |
stop_price | String | 触发价格 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
client_id | String | 客户端id |
total | Integer | 总记录数 |
offset | Integer | 偏移量 |
limit | Integer | 一次获取的记录数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
// Response
"data": {
"order_id": 10,
"market": "BTCUSD",
"type": 1,
"side": 2,
"effect_type": 1,
"stop_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "web",
"state": 1,
"stop_price": "9200",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"client_id": ""
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/stop_status
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 订单id |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
stop_type | Integer | 触发方式 1: 最新成交价, 2: 指数价, 3: 标记价格 |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
state | Integer | 计划单触发价与当前市场价的关系 1:低于当前市场价 2:高于当前市场价 |
stop_price | String | 触发价格 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
client_id | String | 客户端id |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&side=0
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"records": [
{
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
},
...
],
"offset": 10,
"limit": 5
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/finished
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称,空字符串查询所有市场 |
side | Integer | Y | 0: 全部, 1: 卖, 2: 买 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的条数 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
offset | Integer | 偏移量 |
limit | Integer | 一次获取的记录数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&amount=1
&price=1100
&effect_type=1
&option=0
&client_id=client1
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/close_limit
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
position_id | Integer | Y | 仓位ID |
amount | String | Y | 平仓数量 |
price | String | Y | 价格 |
effect_type | Integer | N | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
option | Integer | N | 选项, 1:只下maker单。默认为0 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&amount=1
&client_id=client1
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/close_market
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
position_id | Integer | Y | 仓位ID |
amount | String | N | 平仓数量,不传则为全平 |
client_id | String | N | client_id是订单的自定义ID。目前它仅支持大写和小写字母,数字,连字符和下划线,并且应小于32个字节. |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,默认为1 1: 一直有效直至取消(GTC) 2: 立刻成交或取消(IOC) 3: 完全成交或取消(FOK) |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&amount=1
&type=1
// Response
"data": {
"position_id": 1,
"create_time":1635760817.787848,
"update_time":1636536470.973876,
"market":"BTCUSDT",
"user_id":1415,
"type":1,
"finish_type":1,
"side":2,
"sys":0,
"amount":"2.0000",
"amount_max":"2.0000",
"amount_max_margin":"4000.00",
"close_left":"2.0000",
"open_price":"40000.00",
"open_val":"80000.00",
"open_val_max":"80000.00",
"open_margin":"0.050",
"open_margin_imply":"0.00",
"mainten_margin":"0.005",
"mainten_margin_amount":"400.00",
"margin_amount":"4001.00",
"profit_real":"61270.00",
"profit_clearing":"0",
"adl_sort_val":"0.00049987",
"liq_time":0,
"liq_order_time":0,
"liq_amount":"0.0000",
"liq_profit":"0.00",
"liq_order_price":"0.00",
"take_profit_price":"0.00",
"stop_loss_price":"0.00",
"taker_fee":"0.00000",
"maker_fee":"0.00000",
"take_profit_type":0,
"stop_loss_type":0,
"insurance":"0.00",
"fee_asset":"",
"deal_asset_fee":"0",
"leverage":"20",
"liq_price":"38199.50",
"bkr_price":"37999.50",
"liq_price_imply":"0.00",
"bkr_price_imply":"0.00",
"profit_unreal":"0.00",
"settle_price": "1659.56",
"settle_val": "1576.58200000000000000000",
"adl_sort":1,
"total":1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/adjust_margin
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
amount | String | Y | 调整额度 |
type | Integer | Y | 调整类型, 1: 表示增加保证金,2: 表示减少保证金 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_id | Integer | 仓位id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
market | String | 市场名称 |
user_id | Integer | 用户id |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
side | Integer | 1: 空仓, 2:多仓 |
amount | String | 仓位数量 |
amount_max | String | 历史最大仓位数量 |
amount_max_margin | String | 最大保证金数量 |
close_left | String | 剩余可平 |
open_price | String | 平均开仓价格 |
open_val | String | 累计开仓价值 |
open_val_max | String | 最大开仓价值 |
open_margin | String | 保证金率 |
mainten_margin | String | 维持保证金率 |
mainten_margin_amount | String | 维持保证金数 |
margin_amount | String | 保证金, 起始保证金 + 追加保证金 - 转出保证金 |
profit_real | String | 已实现盈亏 |
profit_clearing | String | 待结算盈亏 |
take_profit_price | String | 止盈价格 |
stop_loss_price | String | 止损价格 |
taker_fee | String | taker手续费 |
maker_fee | String | maker手续费 |
take_profit_type | Integer | 止盈价格类型, 1: 成交价, 3: 标记价 |
stop_loss_type | Integer | 止损价格类型, 1: 成交价, 3: 标记价 |
fee_asset | String | 抵扣手续费的币种 |
deal_asset_fee | String | 已成交手续费 |
leverage | String | 杠杆 |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” |
profit_unreal | String | 未实现盈亏 |
settle_price | String | 结算价格 |
settle_val | String | 结算价值 |
adl_sort | Integer | 自动减仓排序 |
total | Integer | 持仓人数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
// Response
"data": [
{
"position_id": 1,
"create_time": 111.11,
"update_time": 222.11,
"market": "BTCUSD",
"user_id": 2,
"type": 1,
"finish_type": 2,
"side": 1,
"sys": 0,
"amount_max": "120",
"amount_max_margin": "4000.00",
"open_price": "100",
"open_val_max": "0.2",
"mainten_margin": "0.005",
"profit_real": "0.1",
"liq_price": "11.22",
"bkr_price": "11",
"leverage": "10",
"fee_asset": "CET",
"deal_all": "0",
"deal_asset_fee": "0.006",
"settle_price": "1659.56",
"settle_val": "1576.58200000000000000000",
"first_price": "0",
"latest_price": "0",
}
]
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/finished
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
side | Integer | Y | 0:全部 1:卖, 2: 买 |
limit | Integer | Y | 获取的数量 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_id | Integer | 仓位id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
market | String | 市场名称 |
user_id | Integer | 用户id |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
side | Integer | 1: 空仓, 2:多仓 |
amount_max | String | 历史最大仓位数量 |
amount_max_margin | String | 最大保证金数量 |
open_price | String | 平均开仓价格 |
open_val_max | String | 最大开仓价值 |
mainten_margin | String | 维持保证金率 |
profit_real | String | 已实现盈亏 |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” |
leverage | String | 杠杆 |
fee_asset | String | 抵扣手续费的币种 |
deal_all | String | 总成交量 |
deal_asset_fee | String | 已成交手续费 |
settle_price | String | 结算价格 |
settle_val | String | 结算价值 |
first_price | String | 第一笔成交价格 |
latest_price | String | 最近一笔成交价格 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
// Response
"data": [
{
"position_id": 1,
"create_time": 111.11,
"update_time": 222.11,
"market": "BTCUSD",
"user_id": 2,
"type": 1,
"finish_type": 2,
"side": 1,
"sys": 0,
"amount": "100",
"amount_max": "120",
"amount_max_margin": "4000.00",
"close_left": 20,
"open_price": "100",
"open_val": "0.1",
"open_val_max": "0.2",
"open_margin": "0.01",
"open_margin_imply": "0",
"mainten_margin": "0.005",
"mainten_margin_amount": "0.015",
"margin_amount": "1.2",
"profit_real": "0.1",
"profit_clearing": "-1.1",
"adl_sort_val": "1.1",
"liq_time": 111.11,
"liq_order_time": 222.22,
"liq_amount": "10",
"liq_profit": "0.1",
"liq_order_price": "11.11",
"liq_price": "11.22",
"liq_price_imply": "0",
"bkr_price": "11",
"bkr_price_imply": "0",
"leverage": "10",
"adl_sort": 100,
"total": 10,
"fee_asset": "CET",
"deal_asset_fee": "0.006",
"take_profit_price": "109",
"stop_loss_price": "109",
"take_profit_type": 1,
"stop_loss_type": 3,
"profit_unreal": "0.00",
"settle_price": "1659.56",
"settle_val": "1576.58200000000000000000",
"taker_fee": "0.00000",
"maker_fee": "0.00000",
"insurance": "0.00"
}
]
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/pending
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | N | 市场名称 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_id | Integer | 仓位id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
market | String | 市场名称 |
user_id | Integer | 用户id |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
side | Integer | 1: 空仓, 2:多仓 |
amount | String | 仓位数量 |
amount_max | String | 历史最大仓位数量 |
amount_max_margin | String | 最大保证金数量 |
close_left | String | 剩余可平 |
open_price | String | 平均开仓价格 |
open_val | String | 累计开仓价值 |
open_val_max | String | 最大开仓价值 |
open_margin | String | 保证金率 |
mainten_margin | String | 维持保证金率 |
mainten_margin_amount | String | 维持保证金数 |
margin_amount | String | 保证金, 起始保证金 + 追加保证金 - 转出保证金 |
profit_real | String | 已实现盈亏 |
profit_clearing | String | 待结算盈亏 |
take_profit_price | String | 止盈价格 |
stop_loss_price | String | 止损价格 |
taker_fee | String | taker手续费 |
maker_fee | String | maker手续费 |
take_profit_type | Integer | 止盈价格类型, 1: 成交价, 3: 标记价 |
stop_loss_type | Integer | 止损价格类型, 1: 成交价, 3: 标记价 |
fee_asset | String | 抵扣手续费的币种 |
deal_asset_fee | String | 已成交手续费 |
leverage | String | 杠杆 |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” |
profit_unreal | String | 未实现盈亏 |
settle_price | String | 结算价格 |
settle_val | String | 结算价值 |
adl_sort | Integer | 自动减仓排序 |
total | Integer | 持仓人数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"records":[
{
"user_id": 1,
"time": 1111111,
"market": "BTCUSD",
"asset": "BTC",
"type": 1,
"position_id": 2,
"side": 1,
"amount": 20,
"price": "100",
"funding_rate": "0.01",
"funding": "0.2"
},
...
],
"offset": 0,
"limit": 10
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/funding
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的条数 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
user_id | Integer | 用户id |
time | Integer | 时间戳 |
market | String | 市场名称 |
asset | String | 资产名称 |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
position_id | Integer | 仓位id |
side | Integer | 1: 空仓, 2:多仓 |
amount | String | 仓位数量 |
price | String | 价格 |
funding_rate | String | 资金费率 |
funding | String | 资金费 |
offset | Integer | 偏移量 |
limit | Integer | 一次获取记录数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&stop_type=1
&stop_loss_price=1000
// Response
"data": {
"position_id": 1,
"create_time": 111.11,
"update_time": 222.11,
"market": "BTCUSD",
"user_id": 2,
"type": 1,
"finish_type": 2,
"side": 1,
"sys": 0,
"amount": "100",
"amount_max": "120",
"amount_max_margin": "4000.00",
"close_left": 20,
"open_price": "100",
"open_val": "0.1",
"open_val_max": "0.2",
"open_margin": "0.01",
"open_margin_imply": "0",
"mainten_margin": "0.005",
"mainten_margin_amount": "0.015",
"margin_amount": "1.2",
"profit_real": "0.1",
"profit_clearing": "-1.1",
"adl_sort_val": "1.1",
"liq_time": 111.11,
"liq_order_time": 222.22,
"liq_amount": "10",
"liq_profit": "0.1",
"liq_order_price": "11.11",
"liq_price": "11.22",
"liq_price_imply": "0",
"bkr_price": "11",
"bkr_price_imply": "0",
"leverage": "10",
"adl_sort": 100,
"total": 10,
"fee_asset": "CET",
"deal_asset_fee": "0.006",
"take_profit_price": "109",
"stop_loss_price": "109",
"take_profit_type": 1,
"stop_loss_type": 3,
"profit_unreal": "0.00",
"settle_price": "1659.56",
"settle_val": "1576.58200000000000000000",
"taker_fee": "0.00000",
"maker_fee": "0.00000",
"insurance": "0.00"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/stop_loss
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
position_id | Integer | Y | 仓位id |
stop_type | Integer | Y | 1: 成交价, 3: 标记价 |
stop_loss_price | String | Y | 止损价格 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_id | Integer | 仓位id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
market | String | 市场名称 |
user_id | Integer | 用户id |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
side | Integer | 1: 空仓, 2:多仓 |
amount | String | 仓位数量 |
amount_max | String | 历史最大仓位数量 |
amount_max_margin | String | 最大保证金数量 |
close_left | String | 剩余可平 |
open_price | String | 平均开仓价格 |
open_val | String | 累计开仓价值 |
open_val_max | String | 最大开仓价值 |
open_margin | String | 保证金率 |
mainten_margin | String | 维持保证金率 |
mainten_margin_amount | String | 维持保证金数 |
margin_amount | String | 保证金, 起始保证金 + 追加保证金 - 转出保证金 |
profit_real | String | 已实现盈亏 |
profit_clearing | String | 待结算盈亏 |
take_profit_price | String | 止盈价格 |
stop_loss_price | String | 止损价格 |
taker_fee | String | taker手续费 |
maker_fee | String | maker手续费 |
take_profit_type | Integer | 止盈价格类型, 1: 成交价, 3: 标记价 |
stop_loss_type | Integer | 止损价格类型, 1: 成交价, 3: 标记价 |
fee_asset | String | 抵扣手续费的币种 |
deal_asset_fee | String | 已成交手续费 |
leverage | String | 杠杆 |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” |
profit_unreal | String | 未实现盈亏 |
settle_price | String | 结算价格 |
settle_val | String | 结算价值 |
adl_sort | Integer | 自动减仓排序 |
total | Integer | 持仓人数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&stop_type=1
&take_profit_price=1000
// Response
"data": {
"position_id": 1,
"create_time": 111.11,
"update_time": 222.11,
"market": "BTCUSD",
"user_id": 2,
"type": 1,
"finish_type": 2,
"side": 1,
"sys": 0,
"amount": "100",
"amount_max": "120",
"amount_max_margin": "4000.00",
"close_left": 20,
"open_price": "100",
"open_val": "0.1",
"open_val_max": "0.2",
"open_margin": "0.01",
"open_margin_imply": "0",
"mainten_margin": "0.005",
"mainten_margin_amount": "0.015",
"margin_amount": "1.2",
"profit_real": "0.1",
"profit_clearing": "-1.1",
"adl_sort_val": "1.1",
"liq_time": 111.11,
"liq_order_time": 222.22,
"liq_amount": "10",
"liq_profit": "0.1",
"liq_order_price": "11.11",
"liq_price": "11.22",
"liq_price_imply": "0",
"bkr_price": "11",
"bkr_price_imply": "0",
"leverage": "10",
"adl_sort": 100,
"total": 10,
"fee_asset": "CET",
"deal_asset_fee": "0.006",
"take_profit_price": "109",
"stop_loss_price": "109",
"take_profit_type": 1,
"stop_loss_type": 3,
"profit_unreal": "0.00",
"settle_price": "1659.56",
"settle_val": "1576.58200000000000000000",
"taker_fee": "0.00000",
"maker_fee": "0.00000",
"insurance": "0.00"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/take_profit
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 合约市场 |
position_id | Integer | Y | 仓位id |
stop_type | Integer | Y | 1: 成交价, 3: 标记价 |
take_profit_price | String | Y | 止盈价格 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
position_id | Integer | 仓位id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
market | String | 市场名称 |
user_id | Integer | 用户id |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 |
side | Integer | 1: 空仓, 2:多仓 |
amount | String | 仓位数量 |
amount_max | String | 历史最大仓位数量 |
amount_max_margin | String | 最大保证金数量 |
close_left | String | 剩余可平 |
open_price | String | 平均开仓价格 |
open_val | String | 累计开仓价值 |
open_val_max | String | 最大开仓价值 |
open_margin | String | 保证金率 |
mainten_margin | String | 维持保证金率 |
mainten_margin_amount | String | 维持保证金数 |
margin_amount | String | 保证金, 起始保证金 + 追加保证金 - 转出保证金 |
profit_real | String | 已实现盈亏 |
profit_clearing | String | 待结算盈亏 |
take_profit_price | String | 止盈价格 |
stop_loss_price | String | 止损价格 |
taker_fee | String | taker手续费 |
maker_fee | String | maker手续费 |
take_profit_type | Integer | 止盈价格类型, 1: 成交价, 3: 标记价 |
stop_loss_type | Integer | 止损价格类型, 1: 成交价, 3: 标记价 |
fee_asset | String | 抵扣手续费的币种 |
deal_asset_fee | String | 已成交手续费 |
leverage | String | 杠杆 |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” |
profit_unreal | String | 未实现盈亏 |
settle_price | String | 结算价格 |
settle_val | String | 结算价值 |
adl_sort | Integer | 自动减仓排序 |
total | Integer | 持仓人数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/market_close
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
position_id | Integer | Y | 仓位id |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"offset": 10,
"limit": 100,
"records": [
{
"time": 1615233600.7274661,
"market": "BTCUSD",
"asset": "BTC",
"funding_rate": "0.00175",
"funding_rate_real": "0.00175"
}
...
]
}
- 请求类型: GET
- 是否签名: No
- 请求地址: https://api.coinex.com/perpetual/v1/market/funding_history
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的条数 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
time | Float | 时间戳 |
market | String | 市场名称 |
asset | String | 资产名称 |
funding_rate | String | 理论资金费率 |
funding_rate_real | String | 实际资金费率 |
offset | Integer | 偏移量 |
limit | Integer | 一次获取记录数 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
&amount=1
&price=1100
// Response
"data": {
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/modify
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 订单id |
amount | String | N | 委托数量 |
price | String | N | 委托价格 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
order_id | Integer | 订单id |
position_id | Integer | 仓位id |
stop_id | Integer | 计划单id |
market | String | 市场名称 |
type | Integer | 订单类型, 1: 限价单, 2: 市价单 |
side | Integer | 1: 卖, 2: 买 |
effect_type | Integer | 委托生效类型,1: 一直有效直至取消, 2: 立刻成交或取消, 3: 完全成交或取消 |
user_id | Integer | 用户id |
create_time | Float | 创建时间 |
update_time | Float | 更新时间 |
source | String | 来源 |
price | String | 价格 |
amount | String | 数量 |
taker_fee | String | taker费率 |
maker_fee | String | maker费率 |
left | String | 未成交数量 |
deal_stock | String | 已成交的价值 |
deal_fee | String | 已使用手续费 |
deal_profit | String | 已实现收益 |
last_deal_amount | String | 最新交易数量 |
last_deal_price | String | 最新交易价格 |
last_deal_time | Integer | 最新交易时间 |
last_deal_id | Integer | 最新交易id |
last_deal_type | Integer | 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) |
last_deal_role | Integer | 最新交易角色 1: maker 2: taker |
client_id | String | 客户端id |
leverage | String | 杠杆 |
position_type | Integer | 仓位类型 1: 逐仓 2: 全仓 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&order_id=39950
&amount=1
&price=1100
&stop_price=1000
// Response
"data": "success"
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/modify_stop
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称 |
order_id | Integer | Y | 订单id |
amount | String | N | 委托数量 |
price | String | N | 委托价格 |
stop_price | String | N | 触发价格 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"limit": 10,
"offset": 0,
"records": [
{
"amount": "0.20000000",
"deal_id": 1122,
"market": "BTCUSDT",
"order_id": 3322,
"pirce": "40975.66",
"position_id": 2233,
"role": 1,
"side": 1,
"time": 1635760817.787848
}
...
]
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/adl_history
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称,空字符串查询所有市场 |
position_id | Integer | Y | 订单id,0值查询所有仓位 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的数量 |
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
amount | String | 数量 |
deal_id | Integer | 交易id |
market | String | 市场名称 |
order_id | Integer | 订单id |
price | String | 价格 |
position_id | Integer | 仓位id |
role | Integer | 1: maker, 2: taker |
side | Integer | 1: 卖, 2: 买 |
time | Integer | 时间戳 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&client_id=client1
// Response
{
"code": 0,
"data": [
{
"code": 0,
"order": {
"id": 35435975,
"account_id": 0,
"create_time": 1636020972,
"finished_time": 1636020972,
"amount": "1000",
"price": "0",
"deal_amount": "811.88590061",
"deal_money": "43814713.2324293",
"deal_fee": "60763.149707616",
"stock_fee": "0",
"money_fee": "60763.149707616",
"asset_fee": "3269.137012494808",
"fee_asset": "CET",
"fee_discount": "0.7",
"avg_price": "53966.58963963985619139301",
"market": "BTCUSDT",
"left": "0",
"maker_fee_rate": "0",
"taker_fee_rate": "0.0016",
"order_type": "market",
"type": "sell",
"status": "done",
"client_id": ""
},
"message": ""
}
],
"message": "Ok"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel/by_client_id
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | no | 市场名称 |
client_id | String | Yes | client_id是订单的自定义ID。可批量撤销使用同一client_id的订单。 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&client_id=client1
// Response
{
"code": 0,
"data": [
{
"code": 0,
"order": {
"id": 35435975,
"account_id": 0,
"create_time": 1636020972,
"finished_time": 1636020972,
"amount": "1000",
"price": "0",
"deal_amount": "811.88590061",
"deal_money": "43814713.2324293",
"deal_fee": "60763.149707616",
"stock_fee": "0",
"money_fee": "60763.149707616",
"asset_fee": "3269.137012494808",
"fee_asset": "CET",
"fee_discount": "0.7",
"avg_price": "53966.58963963985619139301",
"market": "BTCUSDT",
"left": "0",
"maker_fee_rate": "0",
"taker_fee_rate": "0.0016",
"order_type": "market",
"type": "sell",
"status": "done",
"client_id": ""
},
"message": ""
}
],
"message": "Ok"
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/order/cancel_stop/by_client_id
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | no | 市场名称 |
client_id | String | Yes | client_id是订单的自定义ID。可批量撤销使用同一client_id的订单。 |
timestamp | Integer | Y | 客户端时间戳,单位:毫秒 |
windowtime | Integer | N | 时间窗口,单位:毫秒 |
返回的数据是全局合约市场配置
示例
// Request
timestamp=1513746038205
// Response
{
"code": 0,
"data": {
"settle_switch": 2 // 1: enable settle; 2: disable settle
},
"message": "OK"
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/market/preference
- 返回参数描述:
名称 | 类型 | 描述 |
---|---|---|
settle_switch | Integer | 1: 打开自动结算;2: 关闭自动结算 |
修改的数据是全局合约市场配置
示例
// Request
timestamp=1513746038205
&settle_switch=1
// Response
{
"code": 0,
"message": "Success",
"data": {}
}
- 请求类型: POST
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/market/preference
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
settle_switch | Integer | Yes | 1: 打开自动结算;2: 关闭自动结算 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"limit": 1,
"offset": 0,
"records": [
{
"bkr_price": "0",
"leverage": "3",
"liq_price": "0",
"margin_amount": "205.33333333333333333333",
"margin_change": "111",
"market": "BTCUSDT",
"position_amount": "0.01",
"position_id": 975,
"position_type": 2,
"settle_price": "28300",
"time": 1682413268.680759,
"type": 1,
"user_id": 1367
}
]
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/margin_history
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称,空字符串查询所有市场 |
position_id | Integer | Y | 订单id,0值查询所有仓位 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的数量 |
- 返回参数描述:
名称 | 类型 | 描述 | |
---|---|---|---|
position_id | Integer | 仓位id | |
market | String | 市场名称 | |
user_id | Integer | 用户id | |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 | |
leverage | String | 杠杆 | |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” | |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” | |
settle_price | String | 结算价格 | |
margin_amount | String | 成交后的仓位保证金 | |
margin_change | String | 调整的仓位保证金 | |
position_amount | String | 仓位数量 | |
position_type | Integer | Y | 1 逐仓 2 全仓 |
time | Float | 时间戳 |
示例
// Request
timestamp=1513746038205
&market=ETHUSDT
&position_id=32114
&start_time=1636451914
&end_time=1681724907
&offset=0
&limit=1
// Response
"data": {
"limit": 10,
"offset": 0,
"records": [
{
"time": 1682413268.680759,
"market":"BTCUSDT",
"user_id":1367,
"position_id":975,
"type":5,
"margin_change":"209498",
"margin_amount":"310599.3354",
"liq_price":"0",
"bkr_price":"0",
"position_type":2,
"leverage":"3",
"position_amount":"3100",
"settle_price":"90"
}
...
]
}
- 请求类型: GET
- 是否签名: Yes
- 请求头: “Authorization”: “xxxx”, “AccessId”: “xxx”
- 请求地址: https://api.coinex.com/perpetual/v1/position/settle_history
- 请求参数描述:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
market | String | Y | 市场名称,空字符串查询所有市场 |
position_id | Integer | Y | 订单id,0值查询所有仓位 |
start_time | Integer | N | 开始时间 |
end_time | Integer | N | 结束时间 |
offset | Integer | Y | 偏移量 |
limit | Integer | Y | 获取的数量 |
- 返回参数描述:
名称 | 类型 | 描述 | |
---|---|---|---|
position_id | Integer | 仓位id | |
market | String | 市场名称 | |
user_id | Integer | 用户id | |
type | Integer | 仓位类型, 1: 逐仓, 2:全仓 | |
leverage | String | 杠杆 | |
liq_price | String | 强平价格,当强平价格大于1000000000000时, 返回”Infinity” | |
bkr_price | String | 破产价格,当破产价格大于1000000000000时, 返回”Infinity” | |
settle_price | String | 结算价格 | |
margin_amount | String | 成交后的仓位保证金 | |
margin_change | String | 调整的仓位保证金 | |
position_amount | String | 仓位数量 | |
position_type | Integer | Y | 1 逐仓 2 全仓 |
time | Float | 时间戳 |
WebSocket
websocket地址是 wss://perpetual.coinex.com/
在一个连接中如果对同一个数据重复订阅,前一个订阅会被取消
- 压缩请求
在尝试连接时,需要配置通过 Deflate 算法进行压缩,参考标准为 RFC7692,开发人员大部分使用的 工具库都支持了这一特性,只需要稍加配置即可开启。
右侧示例为 Python 的 websockets 的代码实现:
import websockets
websockets.connect(..., compression='deflate')
- 请求参数描述:
- method: 方法, String.
- params: 参数, Array.
- id: 请求id, Integer
请求示例:
{
"id": 4,
"method": "state.subscribe",
"params": []
}
- 返回结果
- result: Json对象, 失败为null.
- error: Json对象, 成功为null, 失败不为null.
- id: 请求id, Integer.
返回示例:
//success
{
"error": null,
"id": 4,
"result": "success"
}
//success with result
{
"error": null
"id": 4,
"result": {}
}
//error
{
"error": {
"code": 1,
"message": ""
},
"id": 4,
"result": null
}
- 推送
- method: 方法, String
- params: 参数, Array
- id: null
推送示例:
{
"id": null,
"method": "state.update",
"params": []
}
- 错误码描述
错误码 | 错误信息 | 描述 |
---|---|---|
1001 | invalid argument | 无效参数 |
1002 | service unavailable | 服务不可用 |
1003 | service timeout | 服务超时 |
1004 | unknown method | 无效的方法 |
1005 | require auth | 需要授权 |
1006 | internal error | 内部错误 |
1007 | direct result null | 未查找到市场 |
1009 | authorization fail | 授权失败 |
1010 | access_id not exists | AccessId不存在 |
1011 | time check error | 时间检查错误 |
1012 | user is forbid | 用户被禁止 |
1013 | ip not allow visit | ip不允许访问 |
1014 | too quick | 访问频率过快 |
3008 | service too busy | 服务繁忙 |
示例:
// Request
{
"method":"server.sign",
"params": [
"4DA36FFC61334695A66F8D29020EB589",
"3e9e58c40d18358bb129c98139eec99af781275708895e522f572a87dc8d9137",
1513746038205
],
"id": 15,
}
// Response
{
"error": null,
"result": {
"status": "success"
},
"id": 15
}
- 方法: “server.sign”
-
请求参数描述:
名称 类型 是否必须 描述 access_id String Yes access_id sign_data String Yes 对字符串access_id={access_id}×tamp={timestamp}&secret_key={secret_key} 做sha256计算,转换为16进制小写,长度为64位 timestamp Interger Yes 时间戳, 毫秒, 跟服务器时间戳相差不能大于1分钟 -
返回参数描述:
名称 类型 描述 status String 请求结果, 当鉴权成功时返回值为”success”, 鉴权失败信息存在于error字段中
示例:
// Request
{
"method":"server.ping",
"params":[],
"id": 11
}
// Response
{
"error": null,
"result": "pong",
"id": 11
}
- 方法: “server.ping”
-
返回参数描述:
名称 类型 描述 result String “pong”
示例:
// Request
{
"method":"server.time",
"params":[],
"id": 11
}
// Response
{
"error": null,
"result": 1493285895,
"id": 11
}
- 方法: “server.time”
-
返回参数描述:
名称 类型 描述 timestamp Integer 时间戳,单位:秒
示例:
// Request
{
"method":"state.query",
"params":[
"BTCUSD",
86400,
],
"id":15
}
// Response
{
"error": null,
"result": {
"close":"430.33",
"deal":"1574489.5181782117",
"high":"445.68",
"last":"430.33",
"low":"420.32",
"open":"434.11",
"period":86400,
"volume":"3624.85992531",
"funding_time": 10,
"position_amount": "100",
"funding_rate_last": "0.001",
"funding_rate_next": "0.001",
"funding_rate_predict": "0.001",
"insurance": "1000",
"sign_price": "100",
"index_price": "200",
"sell_total": "",
"buy_total": ""
},
"id": 15
}
- 方法: “state.query”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes period, 周期, 例如. 86400为过去24小时 -
返回参数描述:
名称 类型 描述 close String 收盘价 deal String 总交易额 high String 最高价 last String 最新价 low String 最低价 open String 开盘价 period Integer 周期 volume String 总交易量 funding_time String 距离下次资金费用时间,分钟 position_amount String 当前持仓量 funding_rate_last String 上次资金费用 funding_rate_next String 下次资金费用 funding_rate_predict String 预测资金费用 insurance String 当前保险基金 sign_price String 标记价格 index_price String 指数价格 sell_total String 过去1000笔成交中卖单数量 buy_total String 过去1000笔成交中买单数量
示例:
// Request
{
"method":"state.subscribe",
"params":[
"BTCUSD"
],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “state.subscribe”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称, 空为订阅所有市场 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "state.update",
"params": [
{
"BTCUSD": {
"close":"430.33",
"deal":"1574489.5181782117",
"high":"445.68",
"last":"430.33",
"low":"420.32",
"open":"434.11",
"period":86400,
"volume":"3624.85992531",
"funding_time": 10,
"position_amount": "100",
"funding_rate_last": "0.001",
"funding_rate_next": "0.001",
"funding_rate_predict": "0.001",
"insurance": "1000",
"sign_price": "100",
"index_price": "200",
"sell_total": "",
"buy_total": ""
},
}
],
"id": 15
}
- 方法: “state.update”
-
推送参数描述:
名称 类型 描述 close String 收盘价 deal String 总交易额 high String 最高价 last String 最新价 low String 最低价 open String 开盘价 period Integer 周期 volume String 总交易量 funding_time String 距离下次资金费用时间,分钟 position_amount String 当前持仓量 funding_rate_last String 上次资金费用 funding_rate_next String 下次资金费用 funding_rate_predict String 预测资金费用 insurance String 当前保险基金 sign_price String 标记价格 index_price String 指数价格 sell_total String 过去1000笔成交中卖单数量 buy_total String 过去1000笔成交中买单数量
示例:
// Request
{
"method":"state.unsubscribe",
"params":[],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “state.unsubscribe”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method":"depth.query",
"params":[
"BTCUSD",
20,
"0"
],
"id":15
}
// Response
{
"error": null,
"result": {
"bids": [
[
"12.25",
"0.0588"
]
],
"asks": [
[
"12.94",
"0.1524"
]
],
"last": "3740",
"time": 111111,
"sign_price": "3750",
"index_price": "3750",
"checksum": 1533284725
},
"id": 15
}
- 方法: “depth.query”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes limit, 获取记录数, [5, 10, 20, 50]中的其中一个 params[2] Integer Yes interval, 合并深度精度, [“10”, “1”, “0”, “0.1”, “0.01”]的其中一个 -
返回参数描述:
名称 类型 描述 last String 最新价 time Integer 时间戳 sign_price String 标记价 index_price String 指标价 checksum Integer 校验和是全深度数据的有符号的32位整数,用于验证深度数据的准确性。
1. 构造校验和字符串:bid1_price:bid1_amount:bid2_price:bid2_amount:ask1_price:ask1_amout:…(如果没有出价,则校验和字符串是ask1_price:ask1_amount:ask2_price:ask2_amount:…)
2. 将校验和字符串使用crc32算法编码asks[0][0] String 卖一价 asks[0][1] String 卖一量 bids[0][0] String 买一价 bids[0][1] String 买一量
示例:
// Request
{
"method":"depth.subscribe",
"params":[
"BTCBCH",
5,
"0",
true
],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “depth.subscribe”
- 说明: 调用该命令,会取消之前的所有市场深度订阅
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes limit, 获取记录数, [5, 10, 20, 50]中的其中一个 params[2] Integer Yes interval, 合并深度精度, [“10”, “1”, “0”, “0.1”, “0.01”]的其中一个 params[3] Bool No diff, true: 增量订阅, false: 全量订阅, 默认为true -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Request
{
"method":"depth.subscribe_multi",
"params":[
["BTCUSDT", 10, "0", true],
["ETHUSDT", 10, "0", false],
],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “depth.subscribe_multi”
- 说明: 调用该命令,会取消之前的市场深度订阅
-
请求参数描述:
名称 类型 是否必须 描述 params[0][0] String Yes market, 市场名称 params[0][1] Integer Yes limit, 获取记录数, [5, 10, 20, 50]中的其中一个 params[0][2] Integer Yes interval, 合并深度精度, [“10”, “1”, “0”, “0.1”, “0.01”]的其中一个 params[0][3] Bool No diff, true: 增量订阅, false: 全量订阅, 默认为true -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "depth.update",
"params": [
false,
{
"bids": [
[
"12.25",
"0.0588"
]
],
"asks": [
[
"12.94",
"0.1524"
]
],
"last": "3740",
"time": 111111,
"sign_price": "3750",
"index_price": "3750",
"checksum": 1533284725
},
"BTCUSDT"
],
"id": null
}
- 方法: “depth.update”
- 说明:
- params[0]参数表明此次推送是增量推送或是全量推送。
- 增量推送:每次仅推送上个推送时点到当前时点更新的深度数据。每200毫秒推送一次,若无深度更新,则不推送。
- 全量推送:每次推送完整的深度数据。每200毫秒推送一次,若无深度更新,则不推送。
- 如果订阅了多个市场,通过params[2]参数来区分不同市场的推送消息。
- 市场深度每隔1分钟会推送一次全量数据。
-
推送参数描述:
名称 类型 描述 params[0] Bool true: 全量结果,false: 最新增量 last String 最新价 time Integer 时间戳 sign_price String 标记价 index_price String 指标价 checksum Integer 校验和是全深度数据的有符号的32位整数,用于验证深度数据的准确性。
1. 构造校验和字符串:bid1_price:bid1_amount:bid2_price:bid2_amount:ask1_price:ask1_amout:…(如果没有出价,则校验和字符串是ask1_price:ask1_amount:ask2_price:ask2_amount:…)
2. 将校验和字符串使用crc32算法编码asks[0][0] String 卖一价 asks[0][1] String 卖一量 bids[0][0] String 买一价 bids[0][1] String 买一量 params[2] String market, 市场名称
示例:
// Request
{
"method":"depth.unsubscribe",
"params":[],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “depth.unsubscribe”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method":"depth.unsubscribe_multi",
"params":[],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “depth.unsubscribe_multi”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method":"deals.query",
"params":[
"BTCUSDT",
10,
0
],
"id":16
}
// Response
{
"error": null,
"result": [
{
"type": "sell",
"time": 1496458040.059284,
"price": "17868.41",
"id": 29433,
"amount": "10"
}
],
“id": 16
}
- 方法: “deals.query”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes limit, 获取记录数 params[2] Integer Yes last_id, 上次返回结果的最大ID -
返回参数描述:
名称 类型 描述 type String 类型, “sell”: 卖, “buy”: 买 time Float 时间戳 price String 价格 id Integer 编号 amount String 数量
示例:
// Request
{
"method":"deals.query_user",
"params":[
"BTCUSDT",
1,
1637548343,
1637548800,
0,
10,
],
"id":16
}
// Response
{
"error": null,
"result": [
{
"type": "sell",
"time": 1496458040.059284,
"price": "17868.41",
"id": 29433,
"amount": "10"
}
],
“id": 16
}
- 方法: “deals.query_user”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes side, 买卖方向, 0: 所有, 1: 卖, 2: 买 params[2] Integer Yes start_time, 开始时间, 0: 不限制 params[3] Integer Yes end_time, 结束时间, 0: 不限制 params[4] Integer Yes offset, 偏移量,即从哪条开始获取 params[5] Integer Yes limit, 获取记录数 -
返回参数描述:
名称 类型 描述 type String 类型, “sell”: 卖, “buy”: 买 time Float 时间戳 price String 价格 id Integer 编号 amount String 数量
示例:
// Request
{
"method":"deals.subscribe",
"params":[
"BTCBCH"
],
"id":16
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “deals.subscribe”
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> No 市场列表, 空为订阅所有市场 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "deals.update",
"params": [
"BTCUSD",
[
{
"type": "sell",
"time": 1496458040.059284,
"price": "17868.41",
"id": 29433,
"amount": "10"
}
],
true
],
"id": null
}
- 方法: “deals.update”
-
推送参数描述:
名称 类型 描述 params[0] String market, 市场名称 type String 类型, “sell”: 卖, “buy”: 买 time Float 时间戳 price String 价格 id Integer 编号 amount String 数量 params[2] Bool 若该参数为true,表示用户自己的成交。若没有该参数,则为全部用户的成交。
示例:
// Request
{
"method":"deals.unsubscribe",
"params":[],
"id":16
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “deals.unsubscribe”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method":"kline.query",
"params":[
"BTCUSD",
60
],
"id": 5
}
// Response
{
"error": null,
"result": [
[
1496458500,
"16.65",
"11.57",
"17.65",
"10.57",
"1862"
]
],
"id": 5
}
- 方法: “kline.query”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes period, 周期
1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, 1day, 3day, 1week -
返回参数描述:
名称 类型 描述 result[0][0] Integer 时间戳 result[0][1] String 开盘价 result[0][2] String 收盘价 result[0][3] String 最高价 result[0][4] String 最低价 result[0][5] String 数量
示例:
// Request
{
"method":"kline.subscribe",
"params":[
"BTCUSD",
60
],
"id": 5
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “kline.subscribe”
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes period, 周期
1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, 1day, 3day, 1week -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "kline.update",
"params":[
[
1496458500,
"16.65",
"11.57",
"17.65",
"10.57",
"1862"
]
],
"id": null
}
- 方法: “kline.update”
-
推送参数描述:
名称 类型 描述 result[0][0] Integer 时间戳 result[0][1] String 开盘价 result[0][2] String 收盘价 result[0][3] String 最高价 result[0][4] String 最低价 result[0][5] String 数量
示例:
// Request
{
"method":"kline.unsubscribe",
"params":[],
"id": 5
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “kline.unsubscribe”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method": "order.query",
"params": [
"BTCUSD",
0,
0,
10
],
"id": 15
}
// Response
{
"error": null,
"result": {
"limit": 10,
"offset": 0,
"total": 1,
"records": [{
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}]
},
"id": 15
}
- 方法: “order.query”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes side, 0: 所有, 1: 卖, 2: 买 params[2] Integer Yes offset, 偏移量,即从哪条开始获取 params[3] Integer Yes limit, 获取记录数 -
返回参数描述:
名称 类型 描述 total Integer 返回的订单结果数 limit Integer 获取记录数 offset Integer 偏移量 order_id Integer 订单id position_id Integer 仓位id stop_id Integer 计划单id market String 市场名称 type Integer 订单类型, 1: 限价单, 2: 市价单 side Integer 1: 卖, 2: 买 effect_type Integer 委托生效类型,默认为1
1: 一直有效直至取消(GTC)
2: 立刻成交或取消(IOC)
3: 完全成交或取消(FOK)user_id Integer 用户id create_time Float 创建时间 update_time Float 更新时间 source String 来源 price String 价格 amount String 数量 taker_fee String taker费率 maker_fee String maker费率 left String 未成交数量 deal_stock String 已成交的价值 deal_fee String 已使用手续费 deal_profit String 已实现收益 last_deal_amount String 最新交易数量 last_deal_price String 最新交易价格 last_deal_time Integer 最新交易时间 last_deal_id Integer 最新交易id last_deal_type Integer 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) last_deal_role Integer 最新交易角色 1: maker 2: taker client_id String 客户端id leverage String 杠杆 position_type Integer 仓位类型 1: 逐仓 2: 全仓
示例:
// Request
{
"method": "order.query_stop",
"params": [
"BTCUSD",
2,
0,
10
],
"id": 15
}
// Response
{
"error": null,
"result": {
"limit":10,
"offset":0,
"total":1,
"records":[
{
"order_id":7349,
"type":2,
"side":2,
"user_id":1415,
"create_time":1640483587.5513339,
"update_time":1640483587.5513339,
"market":"BTCUSDT",
"source":"test",
"state":1,
"client_id":"",
"target":0,
"effect_type":1,
"stop_type":1,
"stop_price":"45000.00",
"price":"0",
"amount":"10000.0000",
"taker_fee":"0.00050",
"maker_fee":"0.00030",
"fee_asset":"",
"fee_discount":"0"
}
]
},
"id": 15
}
- 方法: “order.query_stop”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params[0] String Yes market, 市场名称 params[1] Integer Yes side, 0: 所有, 1: 卖, 2: 买 params[2] Integer Yes offset, 偏移量,即从哪条开始获取 params[3] Integer Yes limit, 获取记录数 -
返回参数描述:
名称 类型 描述 total Integer 返回的订单结果数 limit Integer 获取记录数 offset Integer 偏移量 order_id Integer 订单id market String 市场名称 type Integer 订单类型, 1: 限价单, 2: 市价单 side Integer 1: 卖, 2: 买 effect_type Integer 委托生效类型,默认为1
1: 一直有效直至取消(GTC)
2: 立刻成交或取消(IOC)
3: 完全成交或取消(FOK)stop_type Integer 触发类型 1: 最新成交价格触发,2: 指数价格触发,3: 标记价格触发 stop_price String 触发价格 user_id Integer 用户id create_time Float 创建时间 update_time Float 更新时间 source String 来源 price String 价格 amount String 数量 taker_fee String taker费率 maker_fee String maker费率 client_id String 客户端id
示例:
// Request
{
"method": "order.subscribe",
"params": ["BTCUSD"],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “order.subscribe”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes market list, 市场列表 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "order.update",
"params": [
3,
{
"order_id": 10,
"position_id": 0,
"stop_id": 1,
"market": "BTCUSD",
"type": 1,
"side": 2,
"target": 2,
"effect_type": 1,
"user_id": 10,
"create_time": 102001.123,
"update_time": 102003.123,
"source": "API",
"price": "9100.1",
"amount": "100",
"taker_fee": "0.005",
"maker_fee": "-0.002",
"left": "80",
"deal_stock": "0.9",
"deal_fee": "0.01",
"deal_profit": "0.1",
"last_deal_amount": "0.1",
"last_deal_price": "9101.1",
"last_deal_time": 111111111,
"last_deal_id": 1,
"last_deal_type": 1,
"last_deal_role": 1,
"client_id": "",
"fee_asset": "",
"fee_discount": "0.03",
"deal_asset_fee": "0.01",
"leverage": "10",
"position_type": 1
}
],
"id": null
}
- 方法: “order.update”
- 鉴权: 需要, 参考server.sign
-
推送参数描述:
名称 类型 描述 params[0] Integer 事件类型, 1: PUT, 2: UPDATE, 3: FINISH order_id Integer 订单id position_id Integer 仓位id stop_id Integer 计划单id market String 市场名称 type Integer 订单类型, 1: 限价单, 2: 市价单 side Integer 1: 卖, 2: 买 effect_type Integer 委托生效类型,默认为1
1: 一直有效直至取消(GTC)
2: 立刻成交或取消(IOC)
3: 完全成交或取消(FOK)user_id Integer 用户id create_time Float 创建时间 update_time Float 更新时间 source String 来源 price String 价格 amount String 数量 taker_fee String taker费率 maker_fee String maker费率 left String 未成交数量 deal_stock String 已成交的价值 deal_fee String 已使用手续费 deal_profit String 已实现收益 last_deal_amount String 最新交易数量 last_deal_price String 最新交易价格 last_deal_time Integer 最新交易时间 last_deal_id Integer 最新交易id last_deal_type Integer 最新交易类型 1: 开仓 2: 加仓 3: 减仓 4: 平仓 5: 减仓 8: 减仓(系统强平) 9: 减仓(自动减仓) 10: 减仓(止盈) 11: 减仓(止损) 12: 平仓(系统强平) 13: 平仓(自动减仓) 14: 平仓(止盈) 15: 平仓(止损) last_deal_role Integer 最新交易角色 1: maker 2: taker client_id String 客户端id leverage String 杠杆 position_type Integer 仓位类型 1: 逐仓 2: 全仓
示例:
// Request
{
"method": "order.unsubscribe",
"params": [],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “order.unsubscribe”
- 鉴权: 需要, 参考server.sign
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method":"asset.query",
"params":["BCH","BTC"],
"id":15
}
// Response
{
"error": null,
"result": {
"BCH": {
"available": "250",
"frozen": "10",
"tranfer": "10",
"balance_total": "11",
"margin", "10"
},
"BTC":{
"available": "250",
"frozen": "10",
"tranfer": "10",
"balance_total": "11",
"margin", "10"
}
},
"id": 15
}
- 方法: “asset.query”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes asset list, 资产列表 -
返回参数描述:
名称 类型 描述 available String 可用的金额 frozen String 冻结的金额 tranfer String 可转的金额 balance_total String 账户余额 margin String 保证金
示例:
// Request
{
"method": "asset.subscribe",
"params": ["BTC"],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “asset.subscribe”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes asset list, 资产列表 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "asset.update",
"params": [
{
"BCH": {
"available": "250",
"frozen": "10",
"tranfer": "10",
"balance_total": "11",
"margin", "10"
}
}
],
"id": null
}
- 方法: “asset.update”
- 鉴权: 需要, 参考server.sign
-
推送参数描述:
名称 类型 描述 available String 可用的金额 frozen String 冻结的金额 tranfer String 可转的金额 balance_total String 账户余额 margin String 保证金
示例:
// Request
{
"method":"asset.unsubscribe",
"params":[],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “asset.unsubscribe”
- 鉴权: 需要, 参考server.sign
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method": "position.query",
"params": [
"BTCUSD"
],
"id": 15
}
// Response
{
"error": null,
"result": [
{
"position_id": 1,
"create_time":1635760817.787848,
"update_time":1636536470.973876,
"market":"BTCUSDT",
"user_id":1415,
"type":1,
"finish_type":1,
"side":2,
"sys":0,
"amount":"2.0000",
"amount_max":"2.0000",
"amount_max_margin":"4000.00",
"close_left":"2.0000",
"settle_price": "100",
"settle_val": "12000",
"open_price":"40000.00",
"open_val":"80000.00",
"open_val_max":"80000.00",
"open_margin":"0.050",
"open_margin_imply":"0.00",
"mainten_margin":"0.005",
"mainten_margin_amount":"400.00",
"margin_amount":"4001.00",
"profit_real":"61270.00",
"profit_clearing":"0",
"adl_sort_val":"0.00049987",
"liq_time":0,
"liq_order_time":0,
"liq_amount":"0.0000",
"liq_profit":"0.00",
"liq_order_price":"0.00",
"take_profit_price":"0.00",
"stop_loss_price":"0.00",
"taker_fee":"0.00000",
"maker_fee":"0.00000",
"take_profit_type":0,
"stop_loss_type":0,
"insurance":"0.00",
"fee_asset":"",
"deal_asset_fee":"0",
"leverage":"20",
"liq_price":"38199.50",
"bkr_price":"37999.50",
"liq_price_imply":"0.00",
"bkr_price_imply":"0.00",
"profit_unreal":"0.00",
"adl_sort":1,
"total":1
},
{
//position detail
}
],
"id": 15
}
- 方法: “position.query”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes market list, 市场列表 -
返回参数描述:
名称 类型 描述 position_id Integer 仓位id create_time Float 创建时间 update_time Float 更新时间 market String 市场名称 user_id Integer 用户id type Integer 仓位类型, 1: 逐仓, 2:全仓 side Integer 1: 空仓, 2:多仓 amount String 仓位数量 amount_max String 历史最大仓位数量 amount_max_margin String 最大保证金数量 close_left String 剩余可平 settle_price String 结算价格 settle_val String 结算价值 open_price String 平均开仓价格 open_val String 累计开仓价值 open_val_max String 最大开仓价值 open_margin String 保证金率 mainten_margin String 维持保证金率 mainten_margin_amount String 维持保证金数 margin_amount String 保证金, 起始保证金 + 追加保证金 - 转出保证金 profit_real String 已实现盈亏 profit_clearing String 待结算盈亏 take_profit_price String 止盈价格 stop_loss_price String 止损价格 taker_fee String taker手续费 maker_fee String maker手续费 take_profit_type Integer 止盈价格类型, 1: 成交价, 3: 标记价 stop_loss_type Integer 止损价格类型, 1: 成交价, 3: 标记价 fee_asset String 抵扣手续费的币种 deal_asset_fee String 已成交手续费 leverage String 杠杆 liq_price String 强平价格,当强平价格大于1000000000000时, 返回”Infinity” bkr_price String 破产价格,当破产价格大于1000000000000时, 返回”Infinity” profit_unreal String 未实现盈亏 adl_sort Integer 自动减仓排序 total Integer 持仓人数
示例:
// Request
{
"method": "position.subscribe",
"params": [
"BTCUSD"
],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “position.subscribe”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes market list, 市场列表 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "position.update",
"params": [
1,
{
"position_id": 1,
"create_time":1635760817.787848,
"update_time":1636536470.973876,
"market":"BTCUSDT",
"user_id":1415,
"type":1,
"finish_type":1,
"side":2,
"sys":0,
"amount":"2.0000",
"amount_max":"2.0000",
"amount_max_margin":"4000.00",
"close_left":"2.0000",
"settle_price": "100",
"settle_val": "12000",
"open_price":"40000.00",
"open_val":"80000.00",
"open_val_max":"80000.00",
"open_margin":"0.050",
"open_margin_imply":"0.00",
"mainten_margin":"0.005",
"mainten_margin_amount":"400.00",
"margin_amount":"4001.00",
"profit_real":"61270.00",
"profit_clearing":"0",
"adl_sort_val":"0.00049987",
"liq_time":0,
"liq_order_time":0,
"liq_amount":"0.0000",
"liq_profit":"0.00",
"liq_order_price":"0.00",
"take_profit_price":"0.00",
"stop_loss_price":"0.00",
"taker_fee":"0.00000",
"maker_fee":"0.00000",
"take_profit_type":0,
"stop_loss_type":0,
"insurance":"0.00",
"fee_asset":"",
"deal_asset_fee":"0",
"leverage":"20",
"liq_price":"38199.50",
"bkr_price":"37999.50",
"liq_price_imply":"0.00",
"bkr_price_imply":"0.00",
"profit_unreal":"0.00",
"adl_sort":1,
"total":1
},
{
//position detail
}
],
"id": null
}
- 方法: “position.update”
- 鉴权: 需要, 参考server.sign
-
推送参数描述:
名称 类型 描述 params[0] Integer 事件 1: 仓位更新(包括开仓和更新), 2: 平仓, 3: 系统平仓, 4: 自动减仓, 5: 强制平仓, 6: 强制平仓警告 position_id Integer 仓位id create_time Float 创建时间 update_time Float 更新时间 market String 市场名称 user_id Integer 用户id type Integer 仓位类型, 1: 逐仓, 2:全仓 side Integer 1: 空仓, 2:多仓 amount String 仓位数量 amount_max String 历史最大仓位数量 amount_max_margin String 最大保证金数量 close_left String 剩余可平 settle_price String 结算价格 settle_val String 结算价值 open_price String 平均开仓价格 open_val String 累计开仓价值 open_val_max String 最大开仓价值 open_margin String 保证金率 mainten_margin String 维持保证金率 mainten_margin_amount String 维持保证金数 margin_amount String 保证金, 起始保证金 + 追加保证金 - 转出保证金 profit_real String 已实现盈亏 profit_clearing String 待结算盈亏 take_profit_price String 止盈价格 stop_loss_price String 止损价格 taker_fee String taker手续费 maker_fee String maker手续费 take_profit_type Integer 止盈价格类型, 1: 成交价, 3: 标记价 stop_loss_type Integer 止损价格类型, 1: 成交价, 3: 标记价 fee_asset String 抵扣手续费的币种 deal_asset_fee String 已成交手续费 leverage String 杠杆 liq_price String 强平价格,当强平价格大于1000000000000时, 返回”Infinity” bkr_price String 破产价格,当破产价格大于1000000000000时, 返回”Infinity” profit_unreal String 未实现盈亏 adl_sort Integer 自动减仓排序 total Integer 持仓人数
示例:
// Request
{
"method": "position.unsubscribe",
"params": [],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “position.unsubscribe”
- 鉴权: 需要, 参考server.sign
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method": "bbo.subscribe",
"params": ["BTCUSDT"],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “bbo.subscribe”
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes market list, 市场列表 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"market": "BTCUSDT"
"time": 1656660154,
"bid_price": "20000",
"bid_amount": "0.1",
"ask_price": "200001",
"ask_amount": "0.15"
}
- 方法: “bbo.update”
-
推送参数描述:
名称 类型 描述 market String 市场名称 time Integer 时间戳 bid_price String 买一价 bid_amount String 买一量 ask_price String 卖一价 ask_amount String 卖一量
示例:
// Request
{
"method": "bbo.unsubscribe",
"params": [],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “bbo.unsubscribe”
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method": "market.subscribe",
"params": [
"BTCUSDT"
],
"id":15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “market.subscribe”
- 鉴权: 需要, 参考server.sign
-
请求参数描述:
名称 类型 是否必须 描述 params Array<String> Yes market list, 市场列表 -
返回参数描述:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "market.update",
"params": [
{
"market": "BTCUSDT",
"timestamp": 1656660154,
"index_price": "20000",
"sign_price": "0.1"
},
],
"id": null
}
- 方法: “market.update”
- 鉴权: 需要, 参考server.sign
-
推送参数描述:
名称 类型 描述 market String 市场名称 timestamp Integer 时间戳 index_price String 指数价格 sign_price String 标记价格
示例:
// Request
{
"method": "market.unsubscribe",
"params": [],
"id": 15
}
// Response
{
"error": null,
"id": 4,
"result": "success"
}
- 方法: “market.unsubscribe”
- 鉴权: 需要, 参考server.sign
-
返回参数描述:
名称 类型 描述 result String 取消订阅结果
示例:
// Request
{
"method": "deals_own.subscribe",
"params": [
"BTCUSDT"
],
"id":15
}
// Response
{
"error": null,
"result": "success",
"id": 15
}
- 方法: “deals_own.subscribe”
- 鉴权: 需要, 参考server.sign
-
请求参数说明:
名称 类型 是否必须 描述 params Array<String> No 市场列表, 空为订阅所有市场 -
返还参数说明:
名称 类型 描述 result String 订阅结果
示例:
// Notify
{
"method": "deals_own.update",
"params": [
"BTCUSDT",
[
{
"type": "sell",
"time": 1496458040.059284,
"price": "46444.74",
"id": 29433,
"amount": "0.00120000",
"order_id": 523941,
"client_id": ""
}
]
],
"id": null
}
- 方法: “deals_own.update”
-
推送参数说明:
名称 类型 描述 params[0] String market, 市场 type String 类型, “sell”: 卖, “buy”: 买 time float 时间戳 price String 价格 id Integer 编号 amount String 数量 order_id Integer 订单id client_id String 客户端id
示例:
// Request
{
"method": "deals_own.unsubscribe",
"params": [],
"id":15
}
// Response
{
"error": null,
"result": "success",
"id": 15
}
- 方法: “deals_own.unsubscribe”
- 鉴权: 需要, 参考server.sign
-
返还参数说明:
名称 类型 描述 result String 取消订阅结果