Back

Help with Cointegration Test

Hello,

I am pretty novice when it comes to quantitative finance and the various disciplines it involves. I just did some code to try and check if EURJPY and USDCAD are cointegrated. Most of the code is taken from another cointegration example I found. I got a good p-value and the test seems to indicate stationarity. Does my code and testing look good? Do you agree with the test results that these pairs are cointegrated? Any help is appreciated. Thank you so much in advance!

Update Backtest







Hi Hugh, the null hypothesis in ADF test is the time series is not stationary. The more negative the statistics, the more likely we are to reject the null hypothesis. The test statistic value here is -3.32. To help determine the ADF statistic, we can refer to the look-up table. -3.32 is less than the value of -2.868 at 5%. This suggests that we can reject the null hypothesis with a significance level of less than 5%. Rejecting the null hypothesis means that the time series is stationary. Hope you enjoy your quant research in QC.

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Jing Wu, thank you! Also, based off the stationary time series I have, how would I trade this spread? What does it mean when the spread is in negative values versus when it's in positive values?

0

There are multiple methods to trade the spread when there is a price divergence. You can refer to this algorithm 

https://www.quantconnect.com/tutorials/strategy-library/intraday-dynamic-pairs-trading-using-correlation-and-cointegration-approach

Besides, we've made a few pairs trading examples, please search "pairs trading" in the strategy library.

https://www.quantconnect.com/tutorials/strategy-library
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


So when the Stationary series crosses into the positive side does that mean the pairs are getting closer or farther apart? And when the stationary series crosses into the negative side does that mean the pairs are getting closer or farther apart? Thank you!

0

If the spread deviates away from its long-term mean, the algorithm should short the stock which price is diverging up and go long the stock which price is diverging down. The position is closed when prices revert back. 

For example, The spread series is spread = y - x*beta - alpha. If spread > pre-defined level, then price y is diverging up, price x is diverging down, long x and short y. If spread < pre-defined level, short x and long y.

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed