Statistical Analysis of an ETF Pair-Quantitative Trading In Python

Subscribe to newsletter

Pair trading, or statistical arbitrage, is one of the oldest forms of quantitative trading. In this post, we are going to present some relevant statistical tests for analyzing the Australia/Canada pair. We chose this pair because these countries’ economies are tied strongly to the commodity sector, therefore they share similar characteristics and could be a good candidate for pair trading.

We first downloaded the data from Yahoo Finance. We downloaded 10 years of data of EWA and EWC, which are the Exchange Traded Funds (ETF) associated with Australia and Canada, respectively.  We then utilized Python to plot the data and perform statistical tests.

The chart below shows the price time series. Visually, these 2 country ETFs move in a similar fashion, more or less.

Subscribe to newsletter https://harbourfrontquant.beehiiv.com/subscribe Newsletter Covering Trading Strategies, Risk Management, Financial Derivatives, Career Perspectives, and More

Quantitative Trading In Python

We next calculated the correlation of returns and obtained 0.7908. The high correlation makes the pair a good candidate for statistical arbitrage.

We then determined the price spread and performed the Augmented Dicker Fuller test for cointegration.

In statistics and econometrics, an augmented Dickey–Fuller test (ADF) tests the null hypothesis that a unit root is present in a time series sample. The alternative hypothesis is different depending on which version of the test is used, but is usually stationarity or trend-stationarity. It is an augmented version of the Dickey–Fuller test for a larger and more complicated set of time series models.

The augmented Dickey–Fuller (ADF) statistic, used in the test, is a negative number. The more negative it is, the stronger the rejection of the hypothesis that there is a unit root at some level of confidence. Read more

The picture below shows the test results. The p-value is less than 0.05; therefore the pair is cointegrated at the 95% confidence level.

cointegration test in python

Finally, we performed the Phillips-Perron test for cointegration on the spread.

In statistics, the Phillips–Perron test (named after Peter C. B. Phillips and Pierre Perron) is a unit root test. That is, it is used in time series analysis to test the null hypothesis that a time series is integrated of order 1… Like the augmented Dickey–Fuller test, the Phillips–Perron test addresses the issue that the process generating data for yt might have a higher order of autocorrelation than is admitted in the test equation—making yt-1 endogenous and thus invalidating the Dickey–Fuller t-test. Read more

The picture below shows the test results. The p-value is less than 0.05; therefore the pair is cointegrated at the 95% confidence level.

cointegration analysis in python

In the next installment, we will implement a trading strategy using this cointegrated pair.

To download the accompanying Excel workbook or Python program for this post:
1. Subscribe to the newsletter. If you're already a subscriber, go to the next step
2. Once subscribed, refer a friend
After completing these steps, you’ll gain access to the file for this post, along with files for a dozen other posts.

Subscribe to newsletter https://harbourfrontquant.beehiiv.com/subscribe Newsletter Covering Trading Strategies, Risk Management, Financial Derivatives, Career Perspectives, and More

Further questions

What's your question? Ask it in the discussion forum

Have an answer to the questions below? Post it here or in the forum

LATEST NEWSStantec recognized by Corporate Knights as one of the world’s top 10 most sustainable companies – eighth overall, first among industry peers
Stantec recognized by Corporate Knights as one of the world’s top 10 most sustainable companies – eighth overall, first among industry peers

EDMONTON, Alberta and NEW YORK, Jan. 22, 2025 (GLOBE NEWSWIRE) — Stantec, a global leader in sustainable design and engineering, was once again recognized in the top 10 of Corporate Knights’ 2025 100 Most Sustainable Corporations in the World—eighth overall and first amongst industry peers. Announced…

Stay up-to-date with the latest news - click here
LATEST NEWSEros Media World cleared by SEC, internal review finds no misconduct
Eros Media World cleared by SEC, internal review finds no misconduct
Stay up-to-date with the latest news - click here
LATEST NEWSADAMA Provides Financial Performance Estimation for the Full Year of 2024
ADAMA Provides Financial Performance Estimation for the Full Year of 2024
Stay up-to-date with the latest news - click here
LATEST NEWSIran says Swiss national who died in prison had photographed military sites
Iran says Swiss national who died in prison had photographed military sites
Stay up-to-date with the latest news - click here
LATEST NEWSVW plans to sell 15% of Traton shares in H1, manager magazin says
VW plans to sell 15% of Traton shares in H1, manager magazin says
Stay up-to-date with the latest news - click here

Leave a Reply