Thursday, August 07, 2008

Divergences and Pairs Trading

Here we see three charts from yesterday's trade: the Standard and Poor's 500 Index (SPY; top chart); the Financial sector ETF (XLF; middle chart); and the Housing sector index ($HGX; bottom chart). Note that, as the S&P 500 Index moved to new highs in the afternoon, the financial and housing stocks failed to follow. This is what's known as a divergence--a discrepancy in path between an index and its component(s)--and it was something I noted in the day's Twitter comments. When you see multiple sectors fail to follow an index higher or lower, it means that a relatively small proportion of high cap stocks are accounting for a good amount of the move in the index. Very often, those narrow moves are not sustainable and are prone to reversal.

But let's dig a little deeper and ask what it *means* when we have divergences such as the above. Traders--particularly those outside institutional settings--tend to think directionally: they trade SPY, XLF, etc. outright for a move either up or down. That's great when the market is moving directionally; not so profitable when the market chops around.

An alternate trade is a relational one, known as a pairs trade, in which we buy one stock, sector, or index and sell another one against it. Instead of trading the market directionally, we're trading the relationship between two assets directionally: we're trading the relative strength of one stock/sector versus another.

The pairs trade, properly constructed, can be a powerful tool precisely because it is not dependent on market trending. In other words, the S&P 500 Index could move higher or lower, but if Financial stocks underperform the index, I'll still make money if I'm short XLF and long SPY. When markets trade in ranges, they are doing so precisely because large traders and investors are reallocating capital among sectors. This environment of sector rotation is perfect for pairs trading, if you can catch the reallocation shifts early.

So now back to divergences. When we see a new high in SPY and Financial and Housing stocks failing to confirm, what we're really seeing is a decline in the pairs relationship of XLF/SPY and $HGX/SPY. Think of that relationship as a single stock that moves each minute: as SPY is moving to high ground and XLF is not following, we are trending lower in XLF/SPY.

The divergence can be an important sign of directional shift in the broad index (which is why I Twittered the observation yesterday), but it can also signal an emerging pairs trend. If you can catch those pairs trends early, you can run a more diversified book--and you can expose yourself to greater opportunity in non-trending market conditions.


dfx said...

I've recently been examining pairs trading. Its always made to seem like such an exact science, but do trading systems really buy odd lot shares in order to get an accurately weighted pairing ?

would you really buy and sell both at the exact same time ? I suppose if the screen shows green, then cash out. I have been doing just simple hedging and I end up adding and removing longs/shorts at whichever point is most advantageous.

What I need the most is charting software that can plot the differential, and TWS does not do this.

Thank you for a very wonderful blog Dr. Brett !

George said...


I think it depends on what type of pairs trading you are talking about. I have read a little on mean-reverting, pairs trading (MRPT), but I have never tried it.

As I understand, MRPT requires the pairs to have a high correlation, and their price ratio should be ranging, otherwise, there is no reasonably steady, mean price ratio to revert back to in order to know when to close your positions (assuming you weren't stopped out).

Don't quote me on that, but, if the price ratio of the pair is trending, then the mean price ratio of the pair would also be trending. I don't see how that could be advantageous to a MRPT strategy. However, I might be missing something.

I believe the divergence of MRPT is based on X number of standard deviations above/below the mean price ratio.

Given that, and using EOD data, a one year chart of the SPY:XLF price ratio shows a pretty good uptrend until about a month ago, with only a few weeks of ranging earlier this year.

From what I've read, and assuming I understand it correctly, that would seem to disqualify SPY and XLF from a MRPT strategy, so I don't think Brett is talking about this type of pairs trading.

Also, you can d/l your data into an Excel spreadsheet and use that to calculate the correlation between the pairs, mean price ratio, and standard deviation, and then chart the results. The formulas are included in Excel.

dfx said...

re: excel - thanks george

also I realized that google docs spreadsheets now let you work with historical data directly.

=GoogleFinance("CHK", "close", "8/1/2008", "30", "1")
=GoogleFinance("UNG", "close", "8/1/2008", "30", "1")

this let's you import the last 30 days.

I think I will work with sector ETFs vs. main index for a while.

Brett Steenbarger, Ph.D. said...

Hi George,

Thanks for the clarification. I'm simply referring to trading relative strength/weakness via pairs, not necessarily a mean-reversion relationship.