Exercise

Are Bitcoin and Ethereum Cointegrated?

Cointegration involves two steps: regressing one time series on the other to get the cointegration vector, and then perform an ADF test on the residuals of the regression. In the last example, there was no need to perform the first step since we implicitly assumed the cointegration vector was \(\small (1,-1)\). In other words, we took the difference between the two series (after doing a units conversion). Here, you will do both steps.

You will regress the value of one cryptocurrency, bitcoin (BTC), on another cryptocurrency, ethereum (ETH). If we call the regression coefficient \(\small b\), then the cointegration vector is simply \(\small (1,-b)\). Then perform the ADF test on BTC \(\small - b \) ETH. Bitcoin and Ethereum prices are pre-loaded in DataFrames BTC and ETH.

Instructions

100 XP
  • Import the statsmodels module for regression and the adfuller function
  • Add a constant to the ETH DataFrame using sm.add_constant()
  • Regress BTC on ETH using sm.OLS(y,x).fit(), where y is the dependent variable and x is the independent variable, and save the results in result.
    • The intercept is in result.params[0] and the slope in result.params[1]
  • Run ADF test on BTC \(\small - b \) ETH