python equivalent for MATLABS vratiotest

Question:

I am following the book Algorithmic Trading and I am on Chapter 2: The Basics of Mean Reversion.

I have a few pairs and their close prices and I want to check the spread of which pair is mean-reverting.

The book uses MATLAB for all its programming and I am using Python.

First, there was a mention of adf function in MATLAB’s package and its equivalent python code is:

from statsmodels.tsa.stattools import adfuller
ad = adfuller(spread, maxlag = 1)

Then there is a mention of cadf and I think its equivalent python code is:

from statsmodels.tsa.stattools import coint
t_statistic, p_value, crit_value = coint(x, y)

However, I cannot find the python equivalent for MATLAB‘s vratiotest.

Please let me know if there is a python function which performs same as MATLAB‘s vratiotest.

Asked By: Ash

||

Answers:

These may not be exactly what you are looking for:

https://arch.readthedocs.io/en/latest/unitroot/generated/arch.unitroot.VarianceRatio.html

arch.unitroot.VarianceRatio

from arch.unitroot import VarianceRatio

Here is the python code for Variance Ratio Test – Lo and MacKinlay

https://mingze-gao.com/posts/lomackinlay1988/

Answered By: God Is One
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.