This is an update of Justin Lent’s original GLD/USO pairs trading algorithm taken from Ernie Chan’s book, Algorithmic Trading. Pairs Trading is a market-neutral type of trading strategy that waits for an irregularity in the correlation between two highly correlated securities, and then goes short on the over-performer and long on the under-performer. A full tutorial on Pairs Trading is available through the Quantopian Lecture series.
Different from the original backtest, this algorithm uses the price of gold from Quandl to calculate spreads rather than the GLD ETF. However, in both algorithms, the GLD ETF is used to hold positions in gold. You can find more datasets like VIX, macroeconomic indicators, news & social media sentiment, and more on Quantopian Data.
A quick note on the backtest date periods: USO/GLD is a good mechanical pair but is not a profitable trade. However this algo should be able to serve as a template to test other interesting pairs trades - would love to see others post suggestions!
Other Quandl Data Examples: