# Mean Reversion

Continuing introduction of fundamental phenomena, or stylized facts of financial markets, underlying quantitative trading.

Mean reversion is the second, of two, force driving prices:

“A price will tend to average over time.” (Wikipedia)

One intellectual challenge in understanding financial markets is internalizing, what appears at first to be, fundamental contradiction: prices are *simultaneously* driven by the *counteracting* forces of both momentum and mean reversion. Up is down, and left is right.

Mean reversion is one of the most generic phenomena, manifesting in myriad beautiful ways across diverse subjects. For example, Ornstein–Uhlenbeck processes are continuous-time stochastic processes for modeling mean-reversion. Cointegration from time-series econometrics is a stationarity property of linear combinations of series. The Bollinger Bands is a technical indicator formed by bracketed upper and lower bounds based upon standard deviation. Mean reversion also forms the basis for entire trading disciplines such as statistical arbitrage and volatility arbitrage.

Mean reversion is nicely illustrated via pairs trading, a classic statistical arbitrage trading strategy. For simplicity, consider closing prices of SPY and PRF during 2007 – 2008. This relationship is potentially interesting, as both are large-cap indices; their difference lies in weighting: PRF is weighted by fundamentals, while SPY is weighted by market capitalization. Price graph over this period is:

Estimation via OLS regression indicates the following relationship:

`PRF = -7.356 + (0.455 * SPY)`

Which explains 98.8% of the observed variance (adjusted R^{2}), with both terms significant (p-values << 0.05). Note standard cointegration tests and related analysis are deliberately being glossed over, for sake of brevity. Graph of estimated versus actual closing prices for PRF, indicates decent fitness:

From this graph, calculate the difference between actual and estimated closing prices for PRF (or, use residuals from above OLS), which can be visualized as the vertical difference between two lines on the preceding graph:

This residuals graph illustrates mean reversion beautifully: SPY and PRF have a long-term relationship whose residual difference reverts to zero (subject to the offset captured by the -7.356 intercept value, which represents the capital cost per share of trading the position). From this knowledge of mean reversion, myriad trading strategies can be devised. For example, go long the SPY/PRF basket when the residual difference exceeds -2; conversely, go short the basket when the residual difference exceeds +1.

This example illustrates several attributes which are common across strategies which rely upon mean reversion:

- Multiple instruments: stability relationship amongst two or more instruments is being exploited
- Residual series: use of a statistical technique, classically OLS (modern techniques range from state space models to Bayesian estimators), to generate a residual time-series composed of a combination of the instruments (either linear or non-linear)
- Statistical tendency: strategy is motivated by statistical likelihood of convergence, given dynamic historical data

Many algorithms exploit mean reversion, whether explicitly or implicitly.

I like your explanation here. It is surprisingly simple for a subject that many view as entirely too complex. Enjoying your blog.

@Sam: thanks for your kind comments.

This blog is off to a wonderful start!

You wrote, “Note standard cointegration tests and related analysis are deliberately being glossed over, for sake of brevity.”

For someone who is self-taught in terms of quantitative and algo trading, is there a particular book you might be able to recommend that would more thoroughly explain the cointegration tests and related analysis?

Thanks!

@Woodshedder: thanks for your complement.

Re cointegration tests: applied cointegration techniques are best described by time-series econometrics (

e.g.Hamilton’s Time Series Analysis) and financial economics textbooks (e.g.Tsay’s Analysis of Financial Time Series), owing to the origination of such techniques by economists Granger and Engle (winners of the 2003 Nobel prize) in their article “Co-integration and error-correction: Representation, estimation and testing”, Econometrica 55: 251–276 (1987).That said, your question motivates a post covering cointegration techniques as applied to trading (using R)—as going from theory to practice is particularly difficult in this domain, as many of the classic theoretical techniques are not terribly useful in quant or algos (or need subtle adjustments).

Quant,

The linear relationship derived by OLS regression was valid for the time period of 2007-2008. This might not be valid in 2009 and 2010. I don’t understand why you would expect the model to hold going forward. I programed this and found that trading this mean reverting relationship in 2009 and 2010 would not have been profitable. Shorting the basket when it reached +1 would have led to losses. Would you need to continuously update the relationship with new data? Say at the end of every month?

Thank you.

@Steve: you are correct; varying regimes require dynamically updating your models.