API Documentation
version - v1 beta

Post Methods

For flexible, fast, low cost queries


[post]

backtest

[post]

cointegration

[post]

copula

[post]

correlations

[post]

spread

[post]

zscores

Get Methods

Data done for you


[get]

backtest

[get]

cointegration

[get]

copula

[get]

correlations

[get]

credits used

[get]

prescanned

[get]

spread

[get]

zscores

API Route - backtest-post

/v1beta/backtest

https://api.cryptowizards.net/v1beta/backtest
Credits: 2

This is a method whereby you provide the api with any price data you wish for rapid turnaround and much lower credits used.


This endpoint is designed to provide you with key backtest metrics.


Hint: If you call the endpoint a ‘with_history’ marked as true, then you will receive spread statistics in addition to cointegration calculations and historical returns too.


This is a very useful endpoint, if you are planning on getting as much information for a pair as possible in one shot.


Gotcha: Different exchanges determine different annual trading days in sharpe calculation. If you know the exchange your data comes from and it matches the exchange list, it is best practice to provide it.


Params Input (part I)

series_1_closes (required)
Include between 50 - 1100 floating point numbers
series_2_closes (required)
Include between 50 - 1100 floating point numbers
series_1_opens (required)
Must match series_1_closes length
series_2_opens (required)
Must match series_2_closes length
strategy (required)
Spread, ZScoreRoll, Copula (copula ignores spread)
exchange
Binance, BinanceUs, ByBit, Coinbase, Dydx, Forex, Stocks. Enter if known
spread_type
Dynamic, Ou, Static - (default Dynamic)
roll_w
Default 42. Rolling window for rolling zscore
with_history
true returns results with extra historical data

Backtest Input (part II)

entry_level
Default 1.5 for ZScoreRoll, 2.0 for Spread, 0.05 for Copula
exit_level
Default 0.0 for ZScoreRoll, 0.0 for Spread, 0.50 for Copula
x_weighting
Default 0.5 (50/50 capital allocation)
slippage_rate
i.e. 0.001 for 0.1%
commission_rate
i.e. 0.001 for 0.1%
exit_n_periods
Number of periods to force an exit
stop_loss_rate
i.e. 0.1 for 10% net return loss to trigger exit

Post Data (combined parts I and II)

params
part I above - see github below for example
bt_inputs
part II above - see github below for example

GitHub Code Examples

Request Body (Curl)

curl -X GET "https://api.cryptowizards.net/v1beta/backtest\
?symbol_1=BTCUSDT\
&symbol_2=ETHUSDT\
&exchange=BinanceUs\
&interval=Daily\
&period=365\
&strategy=ZScoreRoll\
&spread_type=Static\
&roll_w=42\
&with_history=false\
&entry_level=1.5\
&exit_level=0.0\
&x_weighting=0.5\
&slippage_rate=0.0005\
&commission_rate=0.0005\
&stop_loss_rate=0.10"\
-H "Content-Type: application/json" \
-H "X-api-key: REPLACE_WITH_YOUR_API_KEY"

Response

{
  "data": {
    "strat_returns": {
      "annual_return": 0.38046404302965087,
      "mean_period_return": 0.0009031393647029252,
      "total_return": 0.045156968235146255
    },
    "max_drawdown": -0.020151803905214108,
    "sharpe_ratio": 3.3335841328367573,
    "sortino_ratio": 7.180593408757123,
    "cvar": -0.010565051725682562,
    "var": -0.010565051725682562,
    "win_rate": 1.0
  },
  "history": null
}

Response (with History)


{
  "data": {
    "strat_returns": {
      "annual_return": 0.3816672731266737,
      "mean_period_return": 0.0009056342406730877,
      "total_return": 0.04528171203365439
    },
      "max_drawdown": -0.02003485497825187,
      "sharpe_ratio": 3.346531891840665,
      "sortino_ratio": 7.2383483785931775,
      "cvar": -0.010565051725682562,
      "var": -0.010565051725682562,
      "win_rate": 1.0
    },
    "history": {
      "coint_eg": {
        "p_value": 0.29710578989962677,
        "t_stat": -2.56322368880048,
        "cv": -3.5022753919999996,
        "is_coint": false,
        "inc_trend": true
      },
      "spread_stats": {
        "spread": [
          -0.1996769652098902,
          -0.1905905187801219,
          ...
          ],
        "zscore": [
          0.7823911425969057,
          -1.913415314926282,
          ...
        ],
        "zscore_roll": [
          0.0,
          ...,
          -0.8353926481570673
        ],
        "hedge_ratio": 0.6296069572572536,
        "half_life": 6.17975243617321,
        "hurst": 0.7726252452662,
        "sigma0crossings": 7,
        "sigma2crossings": 2,
        "log_used": false,
        "last_zscore": {
          "zscore": -1.0062431839275412,
          "zscore_roll": -0.8353926481570673
        }
      },
      "bt_returns": [
        1.0537806068438267,
        1.0452817120336544,
        ...
      ]
  }
}