13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 27

Cointegration-Based Pairs Trading

using QSTrader

In a previous chapter the concept of cointegration was considered. It was shown how cointegrated

pairs of equities or ETFs could lead to profitable mean-reverting trading opportunities. Two

specific tests were outlined–the Cointegrated Augmented Dickey-Fuller (CADF) test and the

Johansen test–that helped statistically identify cointegrated portfolios.

In this chapter QSTrader will be used to implement an actual trading strategy based on

a (potentially) cointegrating relationship between an equity and an ETF in the commodities

market.

The analysis will begin by forming a hypothesis about a fundamental structural relationship

between the prices of Alcoa Inc., a large aluminum producer, and US natural gas. This structural

relationship will be tested for cointegration via the CADF test using R. It will be shown that

although the prices appear partially correlated, that the null hypothesis of no cointegrating

relationship cannot be rejected.

Despite this a static hedging ratio will be calculated between the two series and a trading

strategy developed, firstly to show how such a strategy might be implemented in QSTrader,

irrespective of performance, and secondly to evalulate the performance on a slightly correlated,

but non-cointegrating pair of assets.

This strategy was inspired by Ernie Chan’s famous GLD-GDX cointegration strategy[32] and a

post[41] by Quantopian CEO, John Fawcett, referencing the smelting of aluminum as a potential

for cointegrated assets.

27.1 The Hypothesis

An extremely important set of processes in chemical engineering are the Bayer process and the

Hall-Héroult process. They are the key steps in smelting aluminum from the raw mineral of

bauxite, via the technique of electrolysis.

Electrolysis requires a substantial amount of electricity, much of which is generated by coal,

hydroelectric, nuclear or combined-cycle gas turbine (CCGT) power. The latter requires natural

gas as its main fuel source. Since the purchase of natural gas for aluminum smelting is likely a

substantial cost for aluminum producers, their profitability is derived in part from the price of

381

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!