A Pairs Trading Example
Post on: 13 Октябрь, 2015 No Comment
by Lumilog on July 26, 2008
Note: Please read the disclaimer. The author is not providing professional investing advice.
While waiting for results from the CFA exam to come in, I thought Id cover an example of a trading technique Ive recently begun test driving, pairs trading .
Pairs trading was something I thought Id invented! Alas like many of my so-called brilliant flashes of insight, a little googling revealed that not only had others come up with it decades earlier, but their techniques were more elegant and robust than my first stab.
The basic idea behind pairs trading is this:
- 1. Find a pair of stocks (or ETFs) whose prices tend to move together.
- 2. If the price movements are indeed highly correlated, then on most days the price per share of Stock A divided by the price per share of Stock B should come out to be about the same number, within a small range.
- 3. But occasionally, you might notice a significant divergence from this average ratio. If you do, enter a pairs trade. This will involve simultaneously shorting one of the stocks while taking a long position in the other.
- 4. At some time in the future when the price ratio (hopefully) reverts to the mean, exit the pair trade, wire that (almost) riskless profit to your checking account, and take your wife out to a nice dinner.
Now anyone familiar with the basic workings of the stock market knows that you can make money in either an up or down market, by using both long and short positions. But the catch is, you have to know which way the market is heading in order to know which to use. Easier said that done, even for the pros.
But with pairs trading, you are performing trades that are (theoretically, at least) market neutral. As long as the pair ratio reverts to the mean, you make money regardless of whether you re-arrive at the mean by the short decreasing in price, the long increasing in price, or both. You dont have to know or even care which way the market is heading.
A second benefit is that pair trade positions can be viewed as a nice additional asset class for ones portfolio, since they should be relatively uncorrelated with your traditional asset classes consisting of long positions in various domestic and international indexes.
So lets illustrate pair trading by an example.
Its January 1, 2007 and Im thinking of trying out some pair trading in the new year. Now I could code up a script to perform correlations between the historical price movements of hundreds of stocks in order to find those that move together, but I have a simpler idea.
I have an inkling that Lowes (LOW ) and Home Depot (HD ) might be highly correlated. To me at least, they are roughly equivalent businesses, and which one I go to depends solely on which one is closer when I need something. Lets examine their closing price-per-share data from the previous year
They definitely do seem to move together. And I could compute a correlation on the price movements to confirm what I see visually. But perhaps a more important question is not is the relationship between LOW and HD highly correlated, but rather is it mean-reverting. Because my making a profit depends upon this.
So I now plot the price of LOW divided by the price of HD, what well call the LOW/HD pair ratio
and this indeed seems to be what I was looking for a price ratio (blue curve) that appears to oscillate around a mean (purple line). And Ive also added the 1-, 2-, and 3-standard deviation lines just to get a feel for how far away from the mean the oscillations might go.
So, we appear to know the habits and patterns of this animal. Time to set a trap and lie in wait
But this creature is dangerous and could eat us alive, so we have to be careful. We see that in 2006 the pair ratio often makes excursions 1 or 2 standard deviations above or below the mean. We could spring the trap then but we might end up making lots of trades for tiny profits, and the commissions could eat us alive too.
Examining the figure above, we do see one time when the ratio appeared to go almost 3 standard deviations from the mean. Therefore that will be our criteria for 2007. If we see an excursion +/- 3 standard deviations from the mean, well enter a pair trade. And whenever the ratio returns to the mean, well exit both positions.
And heres what 2007 ended up looking like.
On July 10, the LOW/HD ratio fell 3 standard deviations below the mean, so we buy LOW long at $29.46 and sell HD short at $38.98.
And a little over a month later, on August 16, 2007, the ratio reverted to the mean so we exited both positions. This turned out to mean selling LOW at $26.42 and covering our HD short at $31.79.
So our long LOW position was a 10.3% loss but the short HD position was a 22.6% gain. Therefore our equal dollar positions averaged out to a 6.1% gain .
Were now back in cash and ready to spring the trap again should a new opportunity arise.
And indeed it shortly does. On September 24, 2007 the ratio has now gone 3 standard deviations above the mean. So this time we end up doing the reverse as the previous time. We take a long position in HD at $33.02 and sell short LOW at $30.10.
And a little less than 2 months later, the ratio has once again reverted to the mean. On November 20, 2007 we sell our long HD position at $27.78 and cover our short LOW position at $22.25.
So we take a 15.9% loss on HD but get a 35.3% gain on LOW. This averages to a 9.7% gain .
And this is the last time we get to pounce in 2007. Thus our two pair trades compounded to a +16.5% annual return. Not bad, considering buy-and-hold would have given you a 27% loss in LOW and 31% loss in HD. (I told you their prices move together)
And further, we were only committed to a pair trade about 3 months of the whole year. While we were waiting we could have kept our money in a low-volatility bond index fund (e.g. VFISX or VBMFX ) to generate fixed income in the mean time. I havent run the exact dates but these returned 8% and 7% respectively if youd held them for all of 2007. So maybe it isnt unrealistic to assume that this would have pushed our +16.5% past the 20%+ return mark.
In balance, though this example used real historical data, its probably making pair trading look easier than it is. Some companies diverge and dont mean revert. And should your mean and standard deviations be based on last year or multiple years? A fixed start and stop date or a moving average? Should you jump in at 2, 2.5, or 3 standard deviation excursions and when do you exit (for both profit and for stop loss).
Backtest to derive your own optimized parameters and have fun.