Statistical Analysis of an ETF Pair-Quantitative Trading In Python

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.

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.

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 NEWSBrookfield to Present at the RBC 2023 Global Financials Conference
Brookfield to Present at the RBC 2023 Global Financials Conference

BROOKFIELD, NEWS, March 03, 2023 (GLOBE NEWSWIRE) — Brookfield Corporation (NYSE: BN, TSX: BN) today announced that Bruce Flatt, Chief Executive Officer, is scheduled to present at the RBC 2023 Global Financials Conference on Tuesday, March 7, 2023, at 8:15am ET. A live webcast will…

Stay up-to-date with the latest news - click here
LATEST NEWSFed’s Barkin calls for deliberate rate hikes to fight ‘exhausting’ inflation
Fed’s Barkin calls for deliberate rate hikes to fight ‘exhausting’ inflation

PALO ALTO — The U.S. central bank will need further, deliberate interest rate hikes to bring inflation back down to its 2% goal, Richmond Federal Reserve Bank President Thomas Barkin said on Friday, noting that while inflation has likely peaked, it may not recede quickly.…

Stay up-to-date with the latest news - click here
LATEST NEWSU.S. court says French, Swiss groups cannot restrict ‘gruyere’ cheese label
U.S. court says French, Swiss groups cannot restrict ‘gruyere’ cheese label

The name “gruyere” can be used to label cheeses from outside of the Gruyère region of Switzerland and France, a U.S. appeals court said on Friday, in a victory for U.S. dairy groups and others. The Richmond, Virginia-based 4th U.S. Circuit Court of Appeals upheld…

Stay up-to-date with the latest news - click here
LATEST NEWSStocks Tick Up After Services Data
Stocks Tick Up After Services Data

U.S. stocks rose Friday and for the week after data on the U.S. services sector showed a resilient economy. 

Stay up-to-date with the latest news - click here
LATEST NEWSGoldman Should Be Ashamed For A “Pump And Dump” On The Rivian IPO
Goldman Should Be Ashamed For A “Pump And Dump” On The Rivian IPO

In his podcast addressing the markets today, Louis Navellier offered the following commentary. Manufacturing Sputters ISM reported on Friday that its non-manufacturing, service index slipped a bit to 55.1 in February, down slightly from 55.2 in January. Since any reading above 50 signals an expansion,…

Stay up-to-date with the latest news - click here

Leave a Reply