数据格式

返回的格式必须为以下两种格式之一(系统自动识别): - 模拟级Tick,以下是JSON数据示例:

  {
      "detail": {
          "eid": "Binance",
          "symbol": "BTC_USDT",
          "alias": "BTCUSDT",
          "baseCurrency": "BTC",
          "quoteCurrency": "USDT",
          "marginCurrency": "USDT",
          "basePrecision": 5,
          "quotePrecision": 2,
          "minQty": 0.00001,
          "maxQty": 9000,
          "minNotional": 5,
          "maxNotional": 9000000,
          "priceTick": 0.01,
          "volumeTick": 0.00001,
          "marginLevel": 10
      },
      "schema":["time", "open", "high", "low", "close", "vol"],
      "data":[
          [1564315200000, 9531300, 9531300, 9497060, 9497060, 787],
          [1564316100000, 9495160, 9495160, 9474260, 9489460, 338]
      ]
  }
  • 实盘级Tick,以下是JSON数据示例: Tick级回测数据(包含盘口深度信息,深度格式为[价格, 数量]的数组。可包含多级深度,asks按价格升序排列,bids按价格降序排列)。
    
    {
      "detail": {
          "eid": "Binance",
          "symbol": "BTC_USDT",
          "alias": "BTCUSDT",
          "baseCurrency": "BTC",
          "quoteCurrency": "USDT",
          "marginCurrency": "USDT",
          "basePrecision": 5,
          "quotePrecision": 2,
          "minQty": 0.00001,
          "maxQty": 9000,
          "minNotional": 5,
          "maxNotional": 9000000,
          "priceTick": 0.01,
          "volumeTick": 0.00001,
          "marginLevel": 10
      },
      "schema":["time", "asks", "bids", "trades", "close", "vol"],
      "data":[
          [1564315200000, [[9531300, 10]], [[9531300, 10]], [[1564315200000, 0, 9531300, 10]], 9497060, 787],
          [1564316100000, [[9531300, 10]], [[9531300, 10]], [[1564316100000, 0, 9531300, 10]], 9497060, 787]
      ]
    }
    
字段 说明
detail 请求数据的品种详细信息,包含计价币名称、交易币名称、精度、最小下单量等
schema 指定data数组中列的属性,区分大小写。仅限于 time, open, high, low, close, vol, asks, bids, trades
data 按照schema设置的列结构记录的数据

detail字段

字段 说明
eid 交易所ID,注意同一交易所的现货与期货使用不同的eid
symbol 交易品种代码
alias 当前交易品种代码在交易所中对应的symbol
baseCurrency 交易币种
quoteCurrency 计价币种
marginCurrency 保证金币种
basePrecision 交易币种精度
quotePrecision 计价币种精度
minQty 最小下单量
maxQty 最大下单量
minNotional 最小下单金额
maxNotional 最大下单金额
priceTick 价格最小变动单位
volumeTick 下单量最小变动单位
marginLevel 期货杠杆倍数
contractType 对于永续合约设置为:swap,回测系统将继续发送资金费率、价格指数请求

特殊列属性asksbidstrades说明:

字段 说明 备注
asks / bids [[价格, 数量], …] 例如实盘级 Tick数据示例中的数据:[[9531300, 10]]
trades [[时间, 方向(0:买,1:卖), 价格, 数量], …] 例如实盘级 Tick数据示例中的数据:[[1564315200000, 0, 9531300, 10]]

期货交易所的永续合约回测时,自定义数据源还需要提供额外的资金费率数据和价格指数数据。只有当请求的行情数据返回时,返回结构中的detail字段包含"contractType": "swap"键值对,回测系统才会继续发送资金费率请求。 当回测系统收到资金费率数据后,才会继续发送价格指数数据请求。

资金费率数据结构如下:

{
    "detail": {
        "eid": "Futures_Binance",
        "symbol": "BTC_USDT.funding",
        "alias": "BTC_USDT.funding",
        "baseCurrency": "BTC",
        "quoteCurrency": "USDT",
        "marginCurrency": "",
        "basePrecision": 8,
        "quotePrecision": 8,
        "minQty": 1,
        "maxQty": 10000,
        "minNotional": 1,
        "maxNotional": 100000000,
        "priceTick": 1e-8,
        "volumeTick": 1e-8,
        "marginLevel": 10
    },
    "schema": [
        "time",
        "open",
        "high",
        "low",
        "close",
        "vol"
    ],
    "data": [
        [
            1584921600000,
            -16795,
            -16795,
            -16795,
            -16795,
            0
        ],
        [
            1584950400000,
            -16294,
            -16294,
            -16294,
            -16294,
            0
        ]
        // ...
    ]
}
  • 相邻周期间隔为8小时
  • 例如币安资金费率每8小时更新一次,资金费率数据为何是 -16795? 这是因为与K线数据一样,为避免网络传输过程中浮点数精度丢失,数据采用整型表示;资金费率数据也可能为负值。

回测系统发出的资金费率数据请求示例:

http://customserver:9090/data?custom=0&depth=20&detail=true&eid=Futures_Binance&from=1351641600&period=86400000&round=true&symbol=BTC_USDT.funding&to=1611244800&trades=0

价格指数数据结构如下:

{
    "detail": {
        "eid": "Futures_Binance",
        "symbol": "BTC_USDT.index",
        "alias": "BTCUSDT",
        "baseCurrency": "BTC",
        "quoteCurrency": "USDT",
        "contractType": "index",
        "marginCurrency": "USDT",
        "basePrecision": 3,
        "quotePrecision": 1,
        "minQty": 0.001,
        "maxQty": 1000,
        "minNotional": 0,
        "maxNotional": 1.7976931348623157e+308,
        "priceTick": 0.1,
        "volumeTick": 0.001,
        "marginLevel": 10,
        "volumeMultiple": 1
    },
    "schema": [
        "time",
        "open",
        "high",
        "low",
        "close",
        "vol"
    ],
    "data": [
        [1584921600000, 58172, 59167, 56902, 58962, 0],
        [1584922500000, 58975, 59428, 58581, 59154, 0],
        // ...
    ]
}

回测系统发出的价格指数数据请求示例:

http://customserver:9090/data?custom=0&depth=20&detail=true&eid=Futures_Binance&from=1351641600&period=86400000&round=true&symbol=BTC_USDT.index&to=1611244800&trades=0