Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md

README.md

API_Docs

现货

REST 行情、交易 API

现货REST接口示例

WebSocket 行情 API

接口类型 接口数据类型 请求方法 类型 描述 需要验签
Websocket 市场行情接口 market.$symbol.kline.$period sub 订阅 KLine 数据
Websocket 市场行情接口 market.$symbol.kline.$period req 请求 KLine 数据
Websocket 市场行情接口 market.$symbol.depth.$type sub 订阅 Market Depth 数据
Websocket 市场行情接口 market.$symbol.depth.$type req 请求 Market Depth 数据
Websocket 市场行情接口 market.$symbol.detail sub 订阅 Market detail 数据
Websocket 市场行情接口 market.$symbol.detail req 请求 Market detail 数据
Websocket 市场行情接口 market.$symbol.trade.detail req 请求 Trade detail 数据
Websocket 市场行情接口 market.$symbol.trade.detail sub 订阅 Trade Detail 数据

C++ API

业务类型 业务名称 请求接口 响应接口 数据流
登录 登录 ReqUserLogin OnRspUserLogin 对话流
登录 登出 ReqUserLogout OnRspUserLogout 对话流
交易 报单录入 ReqOrderInsert OnRspOrderInsert 对话流
交易 报单操作 ReqOrderAction OnRspOrderAction 对话流
私有回报 成交回报 N/A OnRtnTrade 私有流
私有回报 报单回报 N/A OnRtnOrder 私有流
私有回报 会员资金通知 N/A OnRtnTradingAccount 私有流
私有回报 报单录入错误回报 N/A OnErrRtnOrderInsert 私有流
私有回报 报单操作错误回报 N/A OnErrRtnOrderAction 私有流
公共通知 交易状态通知 N/A OnRtnInstrumentStatus 公共流
公共通知 增加交易对通知 N/A OnRtnInsInstrument 公共流
公共通知 删除交易对通知 N/A OnRtnDelInstrument 公共流
查询 会员资金查询请求 ReqQryTradingAccount OnRspQryTradingAccount 查询流
查询 报单查询请求 ReqQryOrder OnRspQryOrder 查询流
查询 成交单查询请求 ReqQryTrade OnRspQryTrade 查询流
查询 会员客户查询请求 ReqQryClient OnRspQryClient 查询流
查询 交易对查询请求 ReqQryInstrument OnRspQryInstrument 查询流
查询 交易对交易状态查询请求 ReqQryInstrumentStatus OnRspQryInstrumentStatus 查询流
查询 普通行情查询请求 ReqQryMarketData OnRspQryMarketData 查询流
查询 客户手续费查询 ReqQryPartClientFee OnRspQryPartClientFee 查询流
行情 主题查询 ReqQryTopic OnRspQryTopic 查询流
行情 订阅主题 ReqSubscribeTopic OnRspSubscribeTopic 对话流
行情 深度行情通知 N/A OnRtnDepthMarketData 私有流

订阅 KLine 数据 market.$symbol.kline.$period

成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据:

{
  "sub": "market.$symbol.kline.$period",
  "id": "id generate by client"
}
参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对 ETH/USDT, LTC/USDT, ETC/BTC, BCH/BTC...
period true string K线周期 1min, 5min, 15min, 30min, 60min,day

正确订阅的例子

正确订阅

{
  "sub": "market.BTC/USDT.kline.1min",
  "id": "id1"
}

订阅成功返回数据的例子

{
  "id": "id1",
  "status": "ok",
  "subbed": "market.BTC/USDT.kline.1min",
  "ts": 1489474081631
}

之后每当 KLine 有更新时,client 会收到数据,例子

{
  "ch": "market.BTC/USDT.kline.1min",
  "ts": 1489474082831,
  "tick": {
    "id": 1489464480,
    "amount": 0.0,
    "count": 0,
    "open": 7962.62,
    "close": 7962.62,
    "low": 7962.62,
    "high": 7962.62,
    "vol": 0.0
  }
}

tick 说明

  "tick": {
    "id": K线id,
    "amount": 成交量,
    "count": 成交笔数,
    "open": 开盘价,
    "close": 收盘价,当K线为最晚的一根时,是最新成交价
    "low": 最低价,
    "high": 最高价,
    "vol": 成交额, 即 sum(每一笔成交价 * 该笔的成交量)
  }

错误订阅的例子

错误订阅(错误的 symbol)

{
  "sub": "market.invalidsymbol.kline.1min",
  "id": "id2"
}

订阅失败返回数据的例子

{
  "id": "id2",
  "status": "error",
  "err-code": "bad-request",
  "err-msg": "invalid topic market.invalidsymbol.kline.1min",
  "ts": 1494301904959
}

错误订阅(错误的 topic)

{
  "sub": "market.BTC/USDT.kline.3min",
  "id": "id3"
}

订阅失败返回数据的例子

{
  "id": "id3",
  "status": "error",
  "err-code": "bad-request",
  "err-msg": "invalid topic market.BTC/USDT.kline.3min",
  "ts": 1494310283622
}

请求 KLine 数据 market.$symbol.kline.$period

{
  "req": "market.$symbol.kline.$period",
  "id": "id generated by client",
  "from": 1533536947, //optional, type: long, 2017-07-28T00:00:00+08:00 至 2050-01-01T00:00:00+08:00 之间的时间点,单位:秒
  "to": 1533536947 //optional, type: long, 2017-07-28T00:00:00+08:00 至 2050-01-01T00:00:00+08:00 之间的时间点,单位:秒,必须比 from 大
}
参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对 ETH/USDT, LTC/USDT, ETC/BTC, BCH/BTC...
period true string K线周期 1min, 5min, 15min, 30min, 60min,day
  • 响应结果

[t1, t5] 假设有 t1 ~ t5 的K线.

  • from: t1, to: t5, return [t1, t5].
  • from: t5, to: t1, which t5 > t1, return [].
  • from: t5, return [t5].
  • from: t3, return [t3, t5].
  • to: t5, return [t1, t5].
  • from: t which t3 < t <t4, return [t4, t5].
  • to: t which t3 < t <t4, return [t1, t3].
  • from: t1 and to: t2, should satisfy 1501171200 < t1 < t2 < 2524579200.
一次最多300条

请求 KLine 数据的例子

{
  "req": "market.BTC/USDT.kline.1min",
  "id": "id10"
}

返回数据的例子

{
  "rep": "market.BTC/USDT.kline.1min",
  "status": "ok",
  "id": "id10",
  "tick": [
    {
      "amount": 17.4805,
      "count":  27,
      "id":     1494478080,
      "open":   10050.00,
      "close":  10058.00,
      "low":    10050.00,
      "high":   10058.00,
      "vol":    175798.757708
    },
    {
      "amount": 15.7389,
      "count":  28,
      "id":     1494478140,
      "open":   10058.00,
      "close":  10060.00,
      "low":    10056.00,
      "high":   10065.00,
      "vol":    158331.348600
    },
    // more KLine data here
  ]
}

订阅 Market Depth 数据 market.$symbol.depth.$type

成功建立和 WebSocket API 的连接之后,向 Server 发送如下格式的数据来订阅数据:

{
  "sub": "market.$symbol.depth.$type",
  "id": "id generated by client"
}
参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对 BTC/USDT, ETH/USDT, LTC/USDT, ETC/BTC...
type true string Depth 类型 step1, step2, step3, step4, step5

正确订阅例子

{
  "sub": "market.BTC/USDT.depth.step2",
  "id": "id1"
}

订阅成功返回数据的例子

{
  "id": "id1",
  "status": "ok",
  "subbed": "market.BTC/USDT.depth.step2",
  "ts": 1489474081631
}

之后每当 depth 有更新时,client 会收到数据,例子

{
  "ch": "market.BTC/USDT.depth.step2",
  "ts": 1489474082831,
  "tick": {
    "bids": [
    [9999.3900,0.0098], // [price, amount]
    [9992.5947,0.0560],
    // more Market Depth data here
    ]
    "asks": [
    [10010.9800,0.0099]
    [10011.3900,2.0000]
    //more data here
    ]
  }
}

tick 说明

  "tick": {
    "bids": [
    [买1价,买1量]
    [买2价,买2量]
    //more data here
    ]
    "asks": [
    [卖1价,卖1量]
    [卖2价,卖2量]
    //more data here
    ]
  }

请求 Market Depth 数据 market.$symbol.depth.$type

{
  "req": "market.$symbol.depth.$type",
  "id": "id generated by client"
}

请求 Market Depth 数据的例子

{
  "req": "market.BTC/USDT.depth.step2",
  "id": "id10"
}

返回数据的例子:

{
  "rep": "market.BTC/USDT.depth.step2",
  "status": "ok",
  "id": "id10",
  "tick": {
    "bids": [
    [9999.3900,0.0098], // [price, amount]
    [9992.5947,0.0560],
    // more Market Depth data here
    ]
    "asks": [
    [10010.9800,0.0099]
    [10011.3900,2.0000]
    //more data here
    ]
  }
}

订阅 Trade Detail 数据 market.$symbol.trade.detail

{
  "sub": "market.$symbol.trade.detail",
  "id": "id generated by client"
}
参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对 ETH/USDT, LTC/USDT, ETC/BTC, BCH/BTC...

正确订阅例子:

{
  "sub": "market.BTC/USDT.trade.detail",
  "id": "id1"
}

订阅成功返回数据的例子:

{
  "id": "id1",
  "status": "ok",
  "subbed": "market.BTC/USDT.trade.detail",
  "ts": 1489474081631
}

之后每当 Trade Detail 有更新时,client 会收到数据,例子:

{
  "ch": "market.BTC/USDT.trade.detail",
  "ts": 1489474082831,
  "tick": {
        "id": 14650745135,
        "ts": 1533265950234,
        "data": [
            {
                "amount": 0.0099,
                "ts": 1533265950234,
                "id": 146507451359183894799,
                "price": 401.74,
                "direction": "buy"
            },
            // more Trade Detail data here
        ]
    }

  ]
  }
}

data 说明:

  "data": [
    {
      "id":        消息ID,
      "price":     成交价,
      "time":      成交时间,
      "amount":    成交量,
      "direction": 成交方向,
      "tradeId":   成交ID,
      "ts":        时间戳
    }
  ]

请求 Trade Detail 数据 market.$symbol.trade.detail

{
  "req": "market.$symbol.trade.detail",
  "id": "id generated by client"
}
  • 仅能获取最近 300 个 Trade Detail 数据

请求 Trade Detail 数据的例子

{
  "req": "market.BTC/USDT.trade.detail",
  "id": "id11"
}

返回数据的例子:

{
  "rep": "market.BTC/USDT.trade.detail",
  "status": "ok",
  "id": "id11",
  "data": [
    {
      "id":        601595424,
      "price":     10195.64,
      "time":      1494495766,
      "amount":    0.2943,
      "direction": "buy",
      "tradeId":   601595424,
      "ts":        1494495766000
    },
    {
      "id":        601595423,
      "price":     10195.64,
      "time":      1494495711,
      "amount":    0.2430,
      "direction": "buy",
      "tradeId":   601595423,
      "ts":        1494495711000
    },
    // more Trade Detail data here
  ]
}

订阅 Market Detail 数据 market.$symbol.detail

{
  "req": "market.$symbol.detail",
  "id": "id generated by client"
}
  • 仅返回当前 Market Detail

订阅 Market Detail 数据的例子

{
  "sub": "market.BTC/USDT.detail",
  "id": "id12"
}

返回数据的例子:

{
  "ch": "market.BTC/USDT.detail",
  "status": "ok",
  "id": "id12",
  "tick": {
    "amount": 12224.2922,
    "open":   9790.52,
    "close":  10195.00,
    "high":   10300.00,
    "ts":     1494496390000,
    "id":     1494496390,
    "count":  15195,
    "low":    9657.00,
    "vol":    121906001.754751
  }
}

请求 Market Detail 数据 market.$symbol.detail

{
  "req": "market.$symbol.detail",
  "id": "id generated by client"
}
  • 仅返回当前 Market Detail

请求 Market Detail 数据的例子

{
  "req": "market.BTC/USDT.detail",
  "id": "id12"
}

返回数据的例子:

{
  "rep": "market.BTC/USDT.detail",
  "status": "ok",
  "id": "id12",
  "tick": {
    "amount": 12224.2922,
    "open":   9790.52,
    "close":  10195.00,
    "high":   10300.00,
    "ts":     1494496390000,
    "id":     1494496390,
    "count":  15195,
    "low":    9657.00,
    "vol":    121906001.754751
  }
}
You can’t perform that action at this time.