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 - cointegration-get

/v1beta/cointegration

https://api.cryptowizards.net/v1beta/cointegration
Credits: 5

This GET method entails extracting data for analysis on your behalf. Note this carries a higher credits requirement. It is recommended to send in your own price data using POST endpoints if possible to increase the number of requests that can be made and at faster speeds.


Cointegration (EG) helps to identify if there is a long term mean reverting stationary relationship for a given pair of assets. EG stands for Engle Granger. This is the test used to check for cointegration.


To determine cointegration, we expect that the t-stat < the critical value (cv) in addition to the p-value being less than 0.05. If this criteria is met, then is_coint will be flagged as true.


If inc_trend shows as true, this simply means that models fit the derived spread better when a trend is assumed. If looking for a stationary timeseries (oscillations up and down around a mean with mean, variance and autocovariance constant irrespective of time), then a trend may not be optimal.


Parameters

symbol_1 (required)
i.e. BTCUSDT (if Binance) or BTC-USD (Coinbase) etc
symbol_2 (required)
i.e. BTCUSDT (if Binance) or BTC-USD (Coinbase) etc
exchange (required)
Binance, BinanceUs, ByBit, Coinbase, Dydx, Forex, Stocks
interval (required)
Daily, Hourly, Min5
period (required)
i.e. 365
spread_type
Dynamic, Ou, Static - (default Dynamic)
roll_w
Rolling window for rolling zscore
with_history
true returns results with extra historical data

GitHub Code Examples

Request Body (Curl)

curl -X GET "https://api.cryptowizards.net/v1beta/cointegration?symbol_1=BTCUSDT\
&symbol_2=ETHUSDT&exchange=Binance&interval=Daily&period=365&spread_type=Static&roll_w=42\
&with_history=false" \
  -H "Content-Type: application/json" \
  -H "X-api-key: REPLACE_WITH_YOUR_API_KEY"

Response

{
  "data": {
    "p_value": 0.9095462189033201,
    "t_stat": -1.2046475596299255,
    "cv": -3.498585183773327,
    "is_coint": false,
    "inc_trend": true
  },
  "history": null
}

Response (with History)

{
  "data": {
    "p_value": 0.9095462189033201,
    "t_stat": -1.2046475596299255,
    "cv": -3.498585183773327,
    "is_coint": false,
    "inc_trend": true
  },
  "history": {
    "spread": [
      -0.048293964169238146,
      -0.04606073255866372,
      ...
    ],
    "zscore": [
      -0.36609003525530315,
      -0.349161132169538,
      ...
    ],
    "zscore_roll": [
      0.0,
      ...
      -2.1615087099114954
    ],
    "hedge_ratio": 0.25128116258971733,
    "half_life": 6.442774277370148,
    "hurst": 1.0051152158260312,
    "sigma0crossings": 7,
    "sigma2crossings": 2,
    "log_used": true,
    "last_zscore": {
      "zscore": -2.3438770448984756, // (normalised spread)
      "zscore_roll": -2.1615087099114954
    }
  }
}