WebSocket API 订阅
订阅 Kline 数据
- channel: biboxsub_spot$pairkline$period
成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据
{
"event": "addChannel",
"channel": "bibox_sub_spot_$pair_kline_$period"
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT ...... | |
period | true | string | K线周期 | 1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, day, week |
正确订阅的例子
- 正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_BIX_BTC_kline_1min"
}
- 订阅成功返回数据的例子
[{
"channel": "bibox_sub_spot_BIX_BTC_kline_1min",
"data_type": 0, //订阅成功返回一次全量数据,之后返回增量
"data":
[
{
"time":1536310020000,
"open":"0.00006614",
"high":"0.00006659",
"low":"0.00006604",
"close":"0.00006652",
"vol":"74056.89597166"
},
{
"time":1536310080000,
"open":"0.00006652",
"high":"0.00006652",
"low":"0.00006652",
"close":"0.00006652",
"vol":"100"
}
]
}]
"data_type"
标识返回的数据是全量还是增量,0-返回全量数据,1-返回增量数据data 说明
"data": {
"time": k线某周期开始时间,
"count": 成交笔数,
"open": 开盘价,
"high": 最高价,
"low": 最低价,
"close": 收盘价
"vol": 成交量
}
之后每当 KLine 有更新时,client 会收到数据,例子
[{
"channel": "bibox_sub_spot_BIX_BTC_kline_1min",
"data_type": 1,
"data":
[
{
"time":1536310020000,
"open":"0.00006614",
"high":"0.00006659",
"low":"0.00006604",
"close":"0.00006652",
"vol":"74056.89597166"
},
{
"time":1536310080000,
"open":"0.00006652",
"high":"0.00006652",
"low":"0.00006652",
"close":"0.00006652",
"vol":"100"
}
]
}]
注:返回增量k线时,每次都返回最新相邻两条kline
错误订阅的例子
- 错误订阅(错误的 pair,大小写敏感)
{
"event": "addChannel",
"channel": "bibox_sub_spot_bix_btc_kline_1min"
}
- 订阅失败返回数据的例子
{
"channel": "bibox_sub_spot_bix_btc_kline_1min",
"error":
{
"code": "3009",
"msg":"推送订阅channel不合法"
}
}
订阅 Market 数据
- channel: bibox_sub_spot_ALL_ALL_market
成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_market"
}
正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_market"
}
订阅成功返回数据的例子
[{
"channel": "bibox_sub_spot_ALL_ALL_market",
"data_type": 0,
"data":
[
{
"id":1,
"coin_symbol":"BIX",
"currency_symbol":"BTC",
"last":"0.00006604",
"high":"0.00006712",
"low":"0.00006421",
"change":"+0.00000121",
"percent":"+1.87%",
"vol24H":"54475636",
"amount":"3571.11",
"last_cny":"2.91",
"high_cny":"2.95",
"low_cny":"2.83",
"last_usd":"0.42",
"high_usd":"0.43",
"low_usd":"0.41"
},
{
"id":2,
"coin_symbol":"BIX",
"currency_symbol":"ETH",
"last":"0.00190235",
"high":"0.00192190",
"low":"0.00181724",
"change":"+0.00008058",
"percent":"+4.42%",
"vol24H":"32059017",
"amount":"59861.18",
"last_cny":"2.90",
"high_cny":"2.93",
"low_cny":"2.77",
"last_usd":"0.42",
"high_usd":"0.42",
"low_usd":"0.40"
},
... //其他交易对行情信息
]
}]
data 说明
{
"id": 交易对id
"coin_symbol": 交易币种
"currency_symbol": 定价币种
"last": 24h最新价
"high": 24h最高价
"low": 24h最低价
"change": 24h涨跌
"percent": 24h涨跌幅
"vol24H": 24h成交量
"amount": 24h成交额
"last_cny": 最新价折算cny
"high_cny": 最高价折算cny
"low_cny": 最低价折算cny
"last_usd": 最新价折算usd
"high_usd": 最高价折算usd
"low_usd": 最低价折算usd
}
之后每当 Market 有更新时,client 会收到数据,例子
[{
"channel": "bibox_sub_spot_ALL_ALL_market",
"data_type": 1,
"data":
[
{
"id":1,
"coin_symbol":"BIX",
"currency_symbol":"BTC",
"last":"0.00006604",
"high":"0.00006712",
"low":"0.00006421",
"change":"+0.00000121",
"percent":"+1.87%",
"vol24H":"54475636",
"amount":"3571.11",
"last_cny":"2.91",
"high_cny":"2.95",
"low_cny":"2.83",
"last_usd":"0.42",
"high_usd":"0.43",
"low_usd":"0.41"
}
]
}]
请求 Depth 数据
- channel: biboxsub_spot$pair_depth
成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据
{
"event": "addChannel",
"channel": "bibox_sub_spot_$pair_depth"
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... |
请求 Depth 数据的例子
正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_BIX_BTC_depth"
}
订阅成功返回数据的例子
[{
"channel": "bibox_sub_spot_BIX_BTC_depth",
"data_type": 0,
"data": {
"pair":"BIX_BTC",
"update_time":1536648343927,
"asks":[
{
"price":"0.0000683",
"volume":"1048.8046"
},
{
"price":"0.00006831",
"volume":"1008.2509"
},
... // other data
],
"bids":[
{
"price":"0.00006801",
"volume":"2.3472"
},
{
"price":"0.00006793",
"volume":"0.3458"
},
... // other data
]
}
}]
data说明
"bids": 买方深度列表
"asks": 卖方深度列表
{
"price": 委托价格,
"volume": 委托数量
}
之后每当 Depth 有更新时,client 都会收到全量数据,例子
[{
"channel": "bibox_sub_spot_BIX_BTC_depth",
"data_type": 1,
"data": {
"pair":"BIX_BTC",
"update_time":1536648343927,
"asks":[
{
"price":"0.0000683",
"volume":"1048.8046"
},
{
"price":"0.00006831",
"volume":"1008.2509"
},
... // other data
],
"bids":[
{
"price":"0.00006801",
"volume":"2.3472"
},
{
"price":"0.00006793",
"volume":"0.3458"
},
... // other data
]
}
}]
订阅 Deals 数据
- channel: biboxsub_spot$pair_deals
{
"event": "addChannel",
"channel": "bibox_sub_spot_$pair_deals"
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... |
请求 Deals 数据的例子
正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_BIX_BTC_deals"
}
订阅成功返回数据的例子
[{
"channel": "bibox_sub_spot_BIX_BTC_deals",
"data_type": 0,
"data":[
{
"id":71890943,
"pair":"BIX_BTC",
"price":"0.00006788",
"amount":"9705.9732",
"time":1536648308000,
"side":2
},
{
"id":71890942,
"pair":"BIX_BTC",
"price":"0.00006788",
"amount":"11914.8712",
"time":1536648308000,
"side":2
},
... // other data
]
}]
data说明
{
"id": 成交历史id,
"pair": 交易对,
"price": 成交均价,
"amount": 成交数量,
"time": 成交时间戳,
"side": taker(主动成交方)成交方向,1-买,2-卖
}
之后每当 Deals 有更新时,client 都会收到增量数据,例子
[{
"channel": "bibox_sub_spot_BIX_BTC_depth",
"data_type": 1,
"data":[
{
"price":"0.00006788",
"amount":"9705.9732",
"time":1536648308000,
"side":2
},
{
"price":"0.00006788",
"amount":"11914.8712",
"time":1536648308000,
"side":2
},
... // other data
]
}]
订阅 Ticker 数据
- channel: biboxsub_spot$pair_ticker
{
"event": "addChannel",
"channel": "bibox_sub_spot_$pair_ticker"
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... |
请求 Ticker 数据的例子
正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_BIX_BTC_ticker"
}
订阅成功返回数据的例子
[{
"channel": "bibox_sub_spot_BIX_BTC_ticker",
"data_type": 0,
"data":{
"pair":"BIX_BTC",
"last":"0.00006837",
"last_usd":"0.43",
"last_cny":"2.96",
"high":"0.00007401",
"low":"0.00006628",
"buy":"0.00006814",
"buy_amount":"2654.5376",
"sell":"0.00006876",
"sell_amount":"170.3094",
"vol":"48027601",
"percent":"-6.73%",
"timestamp":1536650154258,
"base_last_cny":"2.96838961"
}
}]
data说明
"data":{
"pair": 交易对
"last": 最新成交价
"last_cny": 最新成交价,cny计价
"last_usd": 最新成交价,usd计价
"high": 24h最高价
"low": 24h最低价
"buy": 最新买一价
"buy_amount": 买一量
"sell": 最新卖一价
"sell_amount": 卖一量
"vol": 24h成交量
"percent": 24h涨跌幅
"timestamp": 时间戳
"base_last_cny": 最新成交价,cny计价(保留8位小数)
}
之后每当 Ticker 有更新时,client 都会收到数据,例子
[{
"channel": "bibox_sub_spot_BIX_BTC_ticker",
"data_type": 1,
"data":{
"pair":"BIX_BTC",
"last":"0.00006837",
"last_usd":"0.43",
"last_cny":"2.96",
"high":"0.00007401",
"low":"0.00006628",
"buy":"0.00006814",
"buy_amount":"2654.5376",
"sell":"0.00006876",
"sell_amount":"170.3094",
"vol":"48027601",
"percent":"-6.73%",
"timestamp":1536650154258,
"base_last_cny":"2.96838961"
}
}]
订阅 Login 数据
- channel: bibox_sub_spot_ALL_ALL_login
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_login",
"apikey": "thisisyourapikey",
"sign": "thisissigneddata"
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
apikey | true | string | 您在Bibox交易所申请的apikey | ||
sign | true | string | 使用您在Bibox交易所申请的apisecret对整个请求数据进行签名 |
注:订阅Login会推送与用户有关的消息,包括:资产,委托单,成交历史
签名步骤
- 1.签名前数据
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_login",
"apikey": "thisisyourapikey"
}
- 2.根据key升序排列
{
"apikey": "thisisyourapikey",
"channel": "bibox_sub_spot_ALL_ALL_login",
"event": "addChannel"
}
- 3.格式化待签名数据并签名
let data = {
"apikey": "thisisyourapikey",
"channel": "bibox_sub_spot_ALL_ALL_login",
"event": "addChannel"
};
let secret = "thisisyourapisecret";
let sign = CryptoJS.HmacMD5(JSON.stringify(data), secret).toString(); // 签名结果 thisissigneddata
- 4.添加签名结果到请求参数
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_login",
"apikey": "thisisyourapikey",
"sign": "thisissigneddata"
}
完整签名例子
nodejs实现
let CryptoJS = require("crypto-js");
function getSign(data) {
let secret = "your apisecret";
let sdic = Object.keys(data).sort();//sort in ascending
let dataTmp = {};
for(let ki in sdic){
dataTmp[sdic[ki]] = data[sdic[ki]];
}
return CryptoJS.HmacMD5(JSON.stringify(dataTmp), secret).toString();
}
let data = {
"event": "addChannel",
"channel": 'bibox_sub_spot_ALL_ALL_login',
"apikey": "your apikey"
};
let sign = getSign(data);//return the signed data
data.sign = sign;
请求 Login 数据的例子
正确订阅
{
"event": "addChannel",
"channel": "bibox_sub_spot_ALL_ALL_login",
"apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"sign": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
订阅成功返回
[{
"channel": "bibox_sub_spot_ALL_ALL_login",
"data_type": 0,
"data":{ result: '订阅成功' }
}]
之后每当 用户资产、委托单、成交历史 有更新时,client 都会收到数据,例子
现货账户资产
- 关键字 credit --> normal
[{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0", //是否推送压缩数据,0-不压缩,1-压缩
"data_type":1,
"data":{
"assets":{ //资产类型
"normal":{ //现货账户资产
"BIX":{
"balance":"497.59601765", //可用资产
"freeze":"0.00000000" //冻结资产
},
"USDT":{
"balance":"20.52027574",
"freeze":"22.12000000"
}
}
}
}
}]
信用账户资产
- 关键字 assets --> credit
[{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"assets":{ //资产类型
"credit":{ //信用账户资产
"BIX_USDT":{ //交易对
"BIX":{
"balance":"681.74441804", //可用资产
"freeze":"0.00000000" //冻结资产
},
"USDT":{
"balance":"0.21698199",
"freeze":"0.00000000"
}
},
"BTC_USDT":{
"BTC":{
"balance":"100",
"freeze":"0.00000000"
},
"USDT":{
"balance":"10",
"freeze":"0.00000000"
}
}
}
}
}
}]
注:信用账户资产以交易对区分,不同交易对下的相同币种(比如BIX_USDT与BTC_USDT的相同币种USDT)互不相关。
现货委托单
- 关键字 orderpending
[{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"orderpending":{ //委托单类型
"id":159,
"createdAt": 1512756997000,
"account_type":0, //账户类型 0-普通账户
"coin_symbol":"LTC", //交易币种
"currency_symbol":"BTC", //定价币种
"order_side":2, //交易方向,1-买,2-卖
"order_type":2, //订单类型,2-限价单
"price":"0.00900000", //委托价格,市价单是0
"amount":"1.00000000", //委托数量,市价买单是0
"money":"0.00900000", //委托金额,市价卖单是0
"deal_amount":"0.00000000", //已成交数量
"deal_percent":"0.00%", //成交百分比
"unexecuted":"0.00000000", //未成交数量
"status":1 //状态,-1-被拒绝,1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销,6-待撤销
}
}
}]
现货成交历史
- 关键字 history
[{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"history":{ //成交历史
"id":"128345653242332",
"createdAt": 1512756997000,
"account_type":0, //账户类型 0-普通账户
"coin_symbol":"LTC", //交易币种
"currency_symbol":"BTC", //定价币种
"order_side":2, //交易方向,1-买,2-卖
"order_type":2, //订单类型,2-限价单
"price":"0.00886500", //成交价格
"amount":"1.00000000", //成交量
"money":"0.00886500", //成交额,单位是定价币种
"relay_id":"123345677775423", //关联订单id
"fee":0 //手续费
}
}
}]
U本位合约订阅 Kline 数据
- channel: biboxsub_spot$pairkline$period (例如 bibox_sub_spot_4BTC_USDT_kline_1min)
- 参考 订阅 Kline 数据
合约的pair参数: BTCUSDT永续 = 4BTC_USDT、ETHUSDT永续 = 4ETH_USDT、以此类推
data 说明
"data": {
"time": k线某周期开始时间,
"count": 成交笔数,
"open": 开盘价,
"high": 最高价,
"low": 最低价,
"close": 收盘价
"vol": 成交量(合约张数)
}
U本位合约订阅 Market 数据
- channel: bibox_sub_spot_ALL_ALL_market
- 参考 订阅 Market 数据
data 说明
{
"id": 交易对id
"coin_symbol": 交易币种 如:4BTC、4ETH...
"currency_symbol": 定价币种
"last": 24h最新价
"high": 24h最高价
"low": 24h最低价
"change": 24h涨跌
"percent": 24h涨跌幅
"vol24H": 24h成交量(张数)
"amount": 24h成交额(USDT)
"last_cny": 最新价折算cny
"high_cny": 最高价折算cny
"low_cny": 最低价折算cny
"last_usd": 最新价折算usd
"high_usd": 最高价折算usd
"low_usd": 最低价折算usd
}
U本位合约订阅 Depth 数据
- channel: biboxsub_spot$pair_depth (例:bibox_sub_spot_4BTC_USDT_depth)
- 参考 订阅 Depth 数据
合约的pair参数: BTCUSDT永续 = 4BTC_USDT、ETHUSDT永续 = 4ETH_USDT、以此类推
data说明
"bids": 买方深度列表
"asks": 卖方深度列表
{
"price": 委托价格,
"volume": 委托数量(张)
}
U本位合约订阅 Deals 数据
- channel: biboxsub_spot$pair_deals (例:bibox_sub_spot_4BTC_USDT_deals)
- 参考 订阅 Deals 数据
合约的pair参数: BTCUSDT永续 = 4BTC_USDT、ETHUSDT永续 = 4ETH_USDT、以此类推
data说明
{
"id": 成交历史id,
"pair": 交易对, 如:4BTC_USDT、4ETH_USDT...
"price": 成交均价,
"amount": 成交数量,
"time": 成交时间戳,
"side": 成交方向,1-开多,2-开空
}
U本位合约订阅 Ticker 数据
- biboxsub_spot$pair_ticker (例:bibox_sub_spot_4BTC_USDT_ticker)
- 参考 订阅 Ticker 数据
合约的pair参数: BTCUSDT永续 = 4BTC_USDT、ETHUSDT永续 = 4ETH_USDT、以此类推
data说明
"data":{
"pair": 交易对
"last": 最新成交价
"last_cny": 最新成交价,cny计价
"last_usd": 最新成交价,usd计价
"high": 24h最高价
"low": 24h最低价
"buy": 最新买一价
"buy_amount": 买一量(张)
"sell": 最新卖一价
"sell_amount": 卖一量(张)
"vol": 24h成交量(张)
"percent": 24h涨跌幅
"timestamp": 时间戳
"base_last_cny": 最新成交价,cny计价(保留8位小数)
}
U本位合约订阅 Login 数据
- bibox_sub_spot_ALL_ALL_login
- 参考 订阅 Login 数据
返回数据例子
U本位合约资产
- contract_assets
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"contract_assets":{
"user_id":10101010,
"coin_symbol":"USDT",
"balance":"99.1823", // 可用余额
"freeze":"0.7899", // 冻结金额
"profit":"-3.6816",
"margin":"0.7899", // 冻结保证金
"imargin":"0.0000" // 挂单冻结资金
}
}
}
]
U本位合约持仓
- contract_order
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"contract_order":{
"user_id":10101010,
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"order_side":2, // 持仓方向,1开多,2开空
"price":"3949.7850", // 开仓均价
"price_up":"4009.0200", // 挂单开多均价
"price_down":"3946.0300", // 挂单开空均价
"fee_rate":"0.0000",
"contract":2, // 持仓张数
"margin":"1.5799", // 保证金
"imargin":"0.0000", // 挂单占用资金
"icontract_up":1, // 委托开多未成交张数
"icontract_down":0, // 委托开空未成交张数
"leverage":"50", // 杠杆倍数,0代表全仓
"price_force":"4009.0318", // 爆仓价格
"price_alert":"3989.2829", // 爆仓告警价格
"profit":"-3.5492"
}
}
}
]
U本位合约委托单
- contract_pending
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"contract_pending":{
"id":"628754", // 委托订单号
"user_id":10101010,
"client_oid": "1589868279533",
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"order_side":1, // 1开多,2开空
"order_type":1,
"price":"4009.0200", // 挂单价格
"contract":1, // 挂单张数
"order_from":1,
"status":3, // 0,1未成交 2部分成交 3完全成交 4部分取消 5完全取消 6,7 系统取消, >=100 下单失败
"price_deal":"3952.5600", // 成交均价
"contract_deal":1, // 已成交张数
"deal_count":1,
"createdAt":1550671734000, // 下单时间
"updatedAt":1550671734000
}
}
}
]
U本位合约成交记录
- contract_detail
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"contract_detail":{
"order_id":"628754", // 委托订单号
"user_id":10101010,
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"order_side":1, // 1开多,2开空
"order_type":1, // 1市价,2限价
"order_from":1,
"contract":1, // 成交张数
"price":"4009.0200", // 开仓价
"price_deal":"3952.5600", // 成交价
"fee":"0.0000", // 手续费
"is_maker":0, // 是否是maker
"is_cancel":0, // 是否是撤销单
"is_persist":0,
"force_sub":0,
"createdAt":1550671735000, // 生成时间
"updatedAt":1550671735000
}
}
}
]
U本位合约仓位变化记录
- contract_deal_log
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"contract_deal_log":{
"id":"1125899906842966183",
"user_id":10040000,
"type":"1", // 1开仓,2平仓,3爆仓,4减仓
"pair":"4ETH_USDT",
"coin_symbol":"USDT",
"price_open":"182.2091272149", // 开仓均价
"price":"181.1900", // 挂单价格
"price_deal":"181.1900", // 成交价格
"contract":"1", // 成交张数,可能为负
"profit":"0", // 收益
"fee":"0.0011", // 手续费
"order_side":1, // 方向
"createdAt":1572855008209,
"updatedAt":1572855008209
}
}
}
订阅指数
- channel: bibox_sub_spot_ALL_ALL_indexMarket
成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据
{
"event":"addChannel",
"channel":"bibox_sub_spot_ALL_ALL_indexMarket",
"binary":1
}
- 正确订阅
{
"event":"addChannel",
"channel":"bibox_sub_spot_ALL_ALL_indexMarket",
"binary":1
}
- 订阅成功返回数据的例子
[
{
"id":147,
"is_hide":0,
"pair_type":0,
"area_id":15,
"coin_symbol":"ETH",
"currency_symbol":"USDT",
"last":"147.1849",
"high":"148.3986",
"low":"140.4113",
"change":"-0.5364",
"percent":"-0.36%",
"vol24H":"43108",
"amount":"6240970.83",
"last_cny":"989.4382",
"base_last_cny":"",
"high_cny":"997.5971",
"low_cny":"943.9036",
"last_usd":"147.1848",
"high_usd":"148.3985",
"low_usd":"140.4113"
},
{
"id":146,
"is_hide":0,
"pair_type":0,
"area_id":15,
"coin_symbol":"BTC",
"currency_symbol":"USDT",
"last":"3955.1652",
"high":"3993.1069",
"low":"3880.6072",
"change":"+6.1701",
"percent":"+0.16%",
"vol24H":"43109",
"amount":"169654088.16",
"last_cny":"26588.2733",
"base_last_cny":"",
"high_cny":"26843.3333",
"low_cny":"26087.0635",
"last_usd":"3955.1651",
"high_usd":"3993.1068",
"low_usd":"3880.6072"
}
]
- data 说明
{
"id":147,
"is_hide":0,
"pair_type":0,
"area_id":15,
"coin_symbol":"ETH", // 币种符号
"currency_symbol":"USDT", // 计价货币,USDTFUND代表溢价指数
"last":"147.1867", // 最新价格
"high":"148.3986",
"low":"140.4113",
"change":"-0.5346",
"percent":"-0.36%",
"vol24H":"43109",
"amount":"6241118.04",
"last_cny":"989.4508",
"base_last_cny":"",
"high_cny":"997.5971",
"low_cny":"943.9036",
"last_usd":"147.1867",
"high_usd":"148.3985",
"low_usd":"140.4113"
}
之后每当指数有更新时,client 会收到数据,例子
{
"id":147,
"is_hide":0,
"pair_type":0,
"area_id":15,
"coin_symbol":"ETH",
"currency_symbol":"USDT",
"last":"147.1867",
"high":"148.3986",
"low":"140.4113",
"change":"-0.5346",
"percent":"-0.36%",
"vol24H":"43109",
"amount":"6241118.04",
"last_cny":"989.4508",
"base_last_cny":"",
"high_cny":"997.5971",
"low_cny":"943.9036",
"last_usd":"147.1867",
"high_usd":"148.3985",
"low_usd":"140.4113"
}
订阅U本位合约下单价格限制
- channel: bibox_sub_spot_ALL_ALL_contractPriceLimit
成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据
{
"event":"addChannel",
"channel":"bibox_sub_spot_ALL_ALL_contractPriceLimit",
"binary":1
}
- 正确订阅
{
"event":"addChannel",
"channel":"bibox_sub_spot_ALL_ALL_contractPriceLimit",
"binary":1
}
- 订阅成功返回数据的例子
{
"4BTC_USDT":{
"min_up":"2964.4562",
"max_up":"4090.9496",
"min_down":"3814.2670",
"max_down":"4940.7603",
"market_up":"4090.9496",
"market_down":"3814.2670"
},
"4ETH_USDT":{
"min_up":"110.3038",
"max_up":"155.1606",
"min_down":"138.9828",
"max_down":"183.8396",
"market_up":"155.1606",
"market_down":"138.9828"
}
}
- data 说明
{
"4BTC_USDT":{ // 合约符号
"min_up":"2964.4562", // 开多最小价格
"max_up":"4090.9496", // 开多最大价格
"min_down":"3814.2670", // 开空最小价格
"max_down":"4940.7603", // 开空最大价格
"market_up":"4090.9496", // 市价开多最大价格
"market_down":"3814.2670" // 市价开空最小价格
}
}
之后每当下单价格限制有更新时,client 会收到数据,例子
{
"4BTC_USDT":{
"min_up":"2964.4562",
"max_up":"4090.9496",
"min_down":"3814.2670",
"max_down":"4940.7603",
"market_up":"4090.9496",
"market_down":"3814.2670"
},
"4ETH_USDT":{
"min_up":"110.3038",
"max_up":"155.1606",
"min_down":"138.9828",
"max_down":"183.8396",
"market_up":"155.1606",
"market_down":"138.9828"
}
}
币本位合约订阅 Kline 数据
- wss://push.bibox.me/cbc
- channel: biboxsub_spot$pairkline$period (例如 bibox_sub_spot_5BTC_USD_kline_1min)
参考 订阅 Kline 数据
示例
{ event: 'addChannel', channel: 'bibox_sub_spot_5BTC_USD_kline_1min', binary: 0, ver: 8, }
币本位合约的pair参数: BTCUSDT永续 = 5BTC_USD、ETHUSDT永续 = 5ETH_USD、以此类推
data 说明
"data": {
"time": k线某周期开始时间,
"count": 成交笔数,
"open": 开盘价,
"high": 最高价,
"low": 最低价,
"close": 收盘价
"vol": 成交量(合约价值)
}
币本位合约订阅标记价格
- wss://push.bibox.me/cbc
- channel: biboxsub_spot$pairTAGPRICE_kline_1min (例如 bibox_sub_spot_5BTC_USDTAGPRICE_kline_1min)
参考 订阅 Kline 数据
示例
{ event: 'addChannel', channel: 'bibox_sub_spot_5BTC_USDTAGPRICE_kline_1min', binary: 0, ver: 8, }
币本位合约的pair参数: BTCUSDT永续 = 5BTC_USD、ETHUSDT永续 = 5ETH_USD、以此类推
data 说明
"data": {
"time": k线某周期开始时间,
"count": 成交笔数,
"open": 开盘价,
"high": 最高价,
"low": 最低价,
"close": 最新价
"vol": 忽略
}
币本位合约订阅深度
- wss://push.bibox.me/cbc
- channel: biboxsub_spot$pair_depth (例如 bibox_sub_spot_5BTC_USD_depth)
参考 订阅 Depth 数据
示例
{ event: 'addChannel', channel: 'bibox_sub_spot_5BTC_USD_depth', // depth binary: 0, ver: 3, }
币本位合约的pair参数: BTCUSDT永续 = 5BTC_USD、ETHUSDT永续 = 5ETH_USD、以此类推
data 说明
"bids": 买方深度列表
"asks": 卖方深度列表
{
"price": 委托价格,
"volume": 委托价值(USD)
}
币本位合约订阅成交记录
- wss://push.bibox.me/cbc
- channel: biboxsub_spot$pair_deals (例:bibox_sub_spot_5BTC_USD_deals)
参考 订阅 Deals 数据
示例
{ event: 'addChannel', channel: 'bibox_sub_spot_5BTC_USD_deals', binary: 0, }
币本位合约的pair参数: BTCUSDT永续 = 5BTC_USD、ETHUSDT永续 = 5ETH_USD、以此类推
data说明
{
"pair": 交易对
"price": 成交价格,
"amount": 成交价值,
"time": 成交时间戳,
"side": 成交方向,1-开多,2-开空
}
币本位合约订阅最新成交价
- wss://push.bibox.me/cbc
- biboxsub_spot$pair_ticker (例:bibox_sub_spot_5BTC_USD_ticker)
- 参考 订阅 Ticker 数据
币本位合约的pair参数: BTCUSDT永续 = 5BTC_USD、ETHUSDT永续 = 5ETH_USD、以此类推
data说明
"data":{
"pair": 交易对
"last": 最新成交价
"last_cny": 最新成交价,cny计价
"last_usd": 最新成交价,usd计价
"high": 24h最高价
"low": 24h最低价
"buy": 最新买一价
"buy_amount": 买一价值)
"sell": 最新卖一价
"sell_amount": 卖一价值)
"vol": 24h成交价值
"percent": 24h涨跌幅
"timestamp": 时间戳
"base_last_cny": 最新成交价,cny计价(保留8位小数)
}
币本位合约订阅用户数据
- wss://push.bibox.me/cbc
- bibox_sub_spot_ALL_ALL_login
- 参考 订阅 Login 数据
返回数据例子
币本位合约资产
- cbc_assets
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"cbc_assets":{
"b":"1",
"c":"BTC",
"u":100006,
"f":"0",
"m":"0"
}
}
}
]
币本位合约仓位
- cbc_order
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"cbc_order":{
"pt":"0",
"f":"0",
"l":"10",
"sd":2,
"pa":"1.0006153088",
"ui":100006,
"fb0":"0",
"pf":"1.0006148393",
"md":1,
"lc":"0",
"pi":"5BTC_USD",
"mg":"0",
"hc":"0",
"fb":"0",
"po":"0"
}
}
}
]
币本位合约挂单
- cbc_pending
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"cbc_pending":{
"f":"0",
"dp":"0",
"eq":"0",
"p":"11692",
"tif":0,
"q":"1",
"sd":2,
"r":0,
"s":1,
"t":1602750121093,
"ui":100006,
"fz":"0.0000086786",
"fb0":"0",
"of":4,
"pi":"5BTC_USD",
"oi":"432108069716000",
"coi":"1602750117690",
"fb":"0",
"po":false
}
}
}
]
币本位合约成交
- cbc_detail
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"cbc_detail":{
"oi":"432108069715999",//挂单id
"ui":"100006",//用户id
"id":"1125899906842648855",//成交id
"coi":"1602750117684",//自定义id
"pi":"5BTC_USD",//交易对
"sd":1,//
"s":3,//
"ot":2,
"of":4,// 挂单来源
"q":"1",
"p":"11692",//挂单价格
"dp":"10655",//成交价格
"ep":"1",
"f":"0.0000000657",//手续费
"fb":"0",//bix抵扣
"fb0":"0",//优惠券抵扣
"im":0,//是否是maker
"t":1602750121093//成交时间
}
}
}
]
币本位合约持仓被动变化
- cbc_deal_log
[
{
"channel":"bibox_sub_spot_ALL_ALL_login",
"binary":"0",
"data_type":1,
"data":{
"cbc_deal_log":{
"id":"1125899906842654296",// 变化id
"user_id":100006,//用户id
"type":5,//变化类型,1开仓,2平仓,3减仓降低风险等级, 4爆仓清空仓位, 5ADL
"mode":2,//仓位模式 1全仓,2逐仓
"pair":"5BTC_USD",//交易对
"price":"11247.6",//参考价格
"hold_dx":"1",//持仓变化量
"order_side":2,// 仓位方向,1多仓,2空仓
"time":1602755131000//变化时间
}
}
}
]