HTTP

鑑權過程如下

  1. http報文的輸入的參數字符串如下:
    market=BTCUSD&type=buy&price=680&amount=1.0&timestamp=1550743431000

  2. 在上面最後拼接secret_key得到如下:
    market=BTCUSD&type=buy&price=680&amount=1.0&timestamp=1550743431000&secret_key=B51068CF10B34E7789C374AB932696A05E0A629BE7BFC62F
    備註:發送http報文體不需要帶上secret_key參數,該步驟只是為了計算sha256簽名。

  3. 對上面字符串進行sha256即簽名,轉換為16進制小寫,長度為64位,再把這個簽名加入到http的頭中如下:
    Authorization: a174066d9ccbeb33803c2a84e20792d31bed5a6e3da8fca23e38fc8dbb917a13

  4. 在http的頭中增加AccessId,服務端根據AccessId尋找對應的用戶信息
    AccessId: 4DA36FFC61334695A66F8D29020EB589

  5. 服務端收到http報文後,根據AccessId找到用戶的secret key,進行上面同樣的操作,判斷收到的簽名與自己計算的簽名是否相等,如果相等則鑑權成功,否則失敗。

  6. 查看簽名生成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
}
名稱 類型 是否必須 描述
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"
名稱 類型 是否必須 描述
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
}
名稱 類型 是否必須 描述
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
}
名稱 類型 是否必須 描述
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"
}
名稱 類型 是否必須 描述
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"
}
名稱 類型 是否必須 描述
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}&timestamp={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": ""
      }
    ]
  "
}
  • 方法: “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 取消訂閱結果
做市商专属对接人
Telegram @CoinExvipmanager
Email vip@coinex.com