Data Format
A custom data source returns JSON in one of the two formats below, recognized automatically: simulated-tick backtests use K-line data, real-tick backtests use order book depth and trade data. All values are integers scaled by precision; see "Numeric precision" below.
Simulated tick
json
{
"detail": {
"eid": "Binance",
"symbol": "BTC_USDT",
"alias": "BTCUSDT",
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"marginCurrency": "USDT",
"basePrecision": 5,
"quotePrecision": 3,
"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]
]
}
Real tick
The data includes order book depth as arrays of [price, amount], with any number of levels: asks in ascending price order, bids in descending price order.
json
{
"detail": {
"eid": "Binance",
"symbol": "BTC_USDT",
"alias": "BTCUSDT",
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"marginCurrency": "USDT",
"basePrecision": 5,
"quotePrecision": 3,
"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]
]
}
Top-level fields
| Field | Description |
|---|---|
| detail | Details of the requested instrument (currencies, precision, minimum order size...); see "detail field" below |
| schema | Attributes of the columns of the data array, case-sensitive |
| data | The data, laid out by the columns in schema |
Columns available in schema: time, open, high, low, close, vol, asks, bids, trades, position (open interest), data (custom data). The formats of asks, bids and trades:
| Column | Format | Example (from the real-tick sample) |
|---|---|---|
| asks / bids | [[price, amount], ...] | [[9531300, 10]] |
| trades | [[time, side, price, amount], ...], side 0 = buy, 1 = sell | [[1564315200000, 0, 9531300, 10]] |
Numeric precision
Requests always carry round=true, and all values are returned as integers scaled by their precision, so that no floating-point precision is lost in transit:
- Prices (
open,high,low,close, and the prices inasks/bidsandtrades) = actual value × 10^quotePrecision. - Amounts (
vol, and the amounts inasks/bidsandtrades) = actual value × 10^basePrecision.
In the examples above quotePrecision is 3, so 9531300 means a price of 9531.300; basePrecision is 5, so 787 means an amount of 0.00787. Time columns (time and the time in trades) are millisecond timestamps and are not scaled.
detail field
| Field | Description |
|---|---|
| eid | Exchange ID; spot and futures of the same exchange use different eids |
| symbol | Trading instrument code |
| alias | The instrument's symbol on the exchange |
| baseCurrency | Base currency |
| quoteCurrency | Quote currency |
| marginCurrency | Margin currency |
| basePrecision | Base currency precision |
| quotePrecision | Quote currency precision |
| minQty | Minimum order quantity |
| maxQty | Maximum order quantity |
| minNotional | Minimum order amount |
| maxNotional | Maximum order amount |
| priceTick | Minimum price increment |
| volumeTick | Minimum order quantity increment |
| marginLevel | Futures leverage |
| contractType | Set to swap for perpetual contracts; the backtest system then also requests funding rate and price index data |
Funding rates and price index for perpetual contracts
When backtesting perpetual contracts on futures exchanges, the custom data source must also provide funding rate data and price index data:
- The backtest system requests funding rate data only if the
detailof the market data contains"contractType": "swap", and only when the strategy holds a position in that perpetual contract or callsGetFundings(). Ifswapis declared but no funding rate data can be obtained, the backtest fails withsymbol ... not found. - Only after receiving funding rate data does the backtest system request price index data.
- For funding rate data only the
opencolumn is read as the rate, truncated to thepriceTickin the funding data'sdetail, so thatpriceTickmust be small enough (e.g.0.00000001). - Funding rate records are 8 hours apart and, like K-line data, are integers scaled by precision; they can be negative. In the example below
quotePrecisionis 8, so-16795means a funding rate of -0.00016795.
Funding rate data (the requested symbol looks like BTC_USDT.funding):
json
{
"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]
]
}
Example of a funding rate request sent by the backtest system:
url
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
Price index data (the requested symbol looks like BTC_USDT.index):
json
{
"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]
]
}
Example of a price index request sent by the backtest system:
url
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