英文:
python equivalent for MATLABS vratiotest
问题
我正在跟随《Algorithmic Trading》这本书,目前在第2章:均值回归的基础部分。
我有一些货币对及其收盘价格,我想检查哪一对的价差是均值回归的。
该书中使用MATLAB进行所有编程,而我正在使用Python。
首先提到了MATLAB包中的adf
函数,其等价的Python代码是:
from statsmodels.tsa.stattools import adfuller
ad = adfuller(spread, maxlag=1)
然后提到了cadf
,我认为其等价的Python代码是:
from statsmodels.tsa.stattools import coint
t_statistic, p_value, crit_value = coint(x, y)
然而,我找不到MATLAB的vratiotest
的Python等价物。请告诉我是否有一个Python函数可以执行与MATLAB的vratiotest
相同的功能。
英文:
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
.
答案1
得分: 0
https://arch.readthedocs.io/en/latest/unitroot/generated/arch.unitroot.VarianceRatio.html
arch.unitroot.VarianceRatio
from arch.unitroot import VarianceRatio
https://mingze-gao.com/posts/lomackinlay1988/
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论