Type/to search
Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Overview and Starting a Backtest
Backtest Modes and Order Matching
Backtest Configuration and Saving
Supported Languages and Exchanges
Reading Backtest Results
Parameter Optimization
Custom Data Source
Data Format
Custom Data Source Example
Local Backtesting Engine
Backtest Page Shortcuts
Advanced Topics
Data and Research
Extended API Interface

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
FieldDescription
detailDetails of the requested instrument (currencies, precision, minimum order size...); see "detail field" below
schemaAttributes of the columns of the data array, case-sensitive
dataThe 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:

ColumnFormatExample (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 in asks/bids and trades) = actual value × 10^quotePrecision.
  • Amounts (vol, and the amounts in asks/bids and trades) = 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
FieldDescription
eidExchange ID; spot and futures of the same exchange use different eids
symbolTrading instrument code
aliasThe instrument's symbol on the exchange
baseCurrencyBase currency
quoteCurrencyQuote currency
marginCurrencyMargin currency
basePrecisionBase currency precision
quotePrecisionQuote currency precision
minQtyMinimum order quantity
maxQtyMaximum order quantity
minNotionalMinimum order amount
maxNotionalMaximum order amount
priceTickMinimum price increment
volumeTickMinimum order quantity increment
marginLevelFutures leverage
contractTypeSet 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 detail of the market data contains "contractType": "swap", and only when the strategy holds a position in that perpetual contract or calls GetFundings(). If swap is declared but no funding rate data can be obtained, the backtest fails with symbol ... not found.
  • Only after receiving funding rate data does the backtest system request price index data.
  • For funding rate data only the open column is read as the rate, truncated to the priceTick in the funding data's detail, so that priceTick must 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 quotePrecision is 8, so -16795 means 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