
A stationary process is a fundamental concept in time series analysis and is essential for forecasting and statistical modelling of financial data used for certain types of quantitative algorithmic trading strategies. "Pair Trading" is one such quantitative trading strategy that is contingent upon the stationarity of the time series formed by a linear combination of the price time series of a pair of financial assets (e.g. stocks, currencies, commodities).
Stationarity being a necessary condition for this strategy, it becomes crucial to check for its existence in any potential candidate pair of assets. In case such a linear combination of the two asset prices exhibits stationarity, the two assets are said to be “Cointegrated”, that is, they form a “Cointegrated Pair”. Such pairs are candidates for inclusion in Pair Trading strategy, subject to some additional conditions.
The Python "stattools" library has functions for testing stationarity of a time series as well as cointegration.
The adfuller() function is meant for checking if a single time series is mean-reverting or not. For instance, checking a time series for mean reversion before applying an ARIMA model on it.
ADF Statistic: -10.0844
P-value: 1.165 * 10-17

The coint() function is meant for checking if two time series move together over time or not. This property is used in devising a type of market neutral meant reversion trading strategy known as Pair Trading.
Cointegration Test Score: -10.3495
P-value: 3.297 * 10-17

The Engle-Granger Two-Step Test is a method for testing cointegration between two time series. It is widely used in pair trading to identify asset pairs that move together in the long run. It involves using an Ordinary Least Squares (OLS) regression and the Augmented Dickey-Fuller (ADF) test.
Steps:
Hedge Ratio: 1.4983128084959811
ADF Statistic: -10.8724
P-value: 1.357 * 10-19

Key Considerations:
The p-value differs between using coint function and manually running the Engle-Granger Two-Step Cointegration Test (OLS regression + adfuller) because of the way coint function handles critical values and finite sample adjustments.
Manual Engle-Granger ADF test statistic: -10.87243
coint function test statistic: -10.92564
Manual Engle-Granger ADF p-value: 1.3577 * 10-19
coint function p-value: 1.2605 * 10 -18
coint function critical values: [-4.01048603, -3.39854434, -3.08756793]

For the purpose of find cointegrated pairs of assets for Pair Trading, it is better to use the coint function, instead of manually running the Engle-Granger two-step ADF test and using the adfuller function, beause the coint function gives more accurate and robust p-values and hence better estimates of cointegration.
