https://quantra.quantinsti.com/course/python-mean-reversion-strategies-ernest-chan

By Ishan Shah

When you believed that a technology stock is trading cheap due to short-term factors such as loss of client or resignation of CEO and you thought that these factors will fade away soon and the stock will trade much higher in future. So, you bought that stock. This is the principle behind mean reversion strategies.

For example, many investors have bought the Infosys stock when price crashed after the resignation of CEO, Mr. Vishal Sikka because they expect the Infosys stock to trade higher in future when the management issues are solved.

The mean reversion principles can be applied to fundamental factors such as buying a stock with low PE and expecting the PE to rise to historic average PE or industry PE. This approach is commonly followed by a value investor to buy the stock for long-term investments. Similarly, these principles can be applied using technical indicators to create a short-term mean reversion trading strategies. These strategies are typically used by hedge funds.

Let’s see building blocks of a simple mean reversion strategy: buy low and sell high. The strategy is built using three steps as shown below.

- Calculate mean
- Determine entry points
- Place the orders

### Calculate mean

A price is expected to stay around the mean. The mean can be calculated using simple moving average or exponential moving average.

### Determine entry points

This is the most critical step in the mean reversion strategy. Here you determine the entry points for your strategy, that is, you quantify significant deviation. This value can be set to +/- 2 * standard deviations from mean or to +/-5% of mean value. Here 2 and 5 are the free parameters to be optimized using a training data set.

### Place the orders

Buy the stock when the price is significantly lower than mean price as the price is expected to rise back to mean and exit the long position when the price goes back to mean. Similarly, sell the stock when the price is significantly higher than mean as the price is expected to go back to mean and exit the short position when the price goes back to mean.

Above mean reversion strategy can be implemented on Tata Motors in following way. In the graph below let's say the mean price of the stock is 400. This is shown using a green line. However, in practical trading, mean is computed daily using recent prices. Then, set the entry points to +/- 50 points for the mean price of 400. This is shown using a blue line. Buy the stock when the price falls below 350 and exit the position when the price rises back to 400 (mean). Similarly, sell the stock when the price rises above 450 and exit the position when price moves back to 400.

Four years Tata Motors price series

To improve strategy performance and protect the strategy from huge drawdown, one or more of the below combination can be used.

### Profit cap

Exit the position when a prefixed profit is achieved. In the above example, when the price reverts to the mean, we have exited the position. In other words, there is a profit cap of 50.

### Stop loss

Exit the position when a prefixed loss is hit. In the above example, we can exit the position when there is a loss of 25. The stop loss is shown using cyan line.

### Fixed holding period

We will only keep the position for a month and exit after that. Once, we have exited the position based on time, we will wait for the price to revert to mean to initiate fresh positions.

### Not to take positions during abnormal price movements

Apart from above stock specific enhancement to protect from drawdown, we can run multiple uncorrelated strategies on a large number of stocks.

An Important point to note is that the mean reversion strategy will only work on a range bound or stationary stock price series. The strategy will not work on a stock price series which trends higher or trends lower for long period of time. To check if price series is stationary or not a statistical technique called as augmented Dickey-Fuller (ADF) test is the most commonly used.

Unfortunately, most stocks price series are not stationary. But fortunately, we can create a portfolio of stocks such that market value of that portfolio is stationary and implement a profitable mean reversion trading strategy on that portfolio. This forms the basis on which pairs trading, triplet trading, index arbitrage and long-short portfolio trading strategies are built.

**Next Step**

Learn Mean Reversion Strategies in detail. Take our exclusive course, developed in association with Dr. Ernest P Chan. Click here to know more about the course.