Skip to content
All library documents

Using Log Price Ratios and Bollinger Bands for Pairs Trading

Article Quant Q&A · Author: Don Chambers

Summary

The document answers a question about how to define entry and exit signals for a pairs trade. It recommends tracking the moving average and standard deviation of the log price ratio between two stocks, rather than comparing a single period’s return difference. When the ratio moves a chosen number of standard deviations above its average, the example goes long one stock and short the other; a move below the threshold reverses those positions. The suggested exit is a return of the ratio to its moving average.

The approach is presented as a standard Bollinger Band application to a relative price series. The answer identifies parameters to explore, including the lookback window, signal threshold, exit timing, and sizing based on the strength of the expected reversion. It cautions that selecting suitable pairs is a separate and essential problem, and suggests exiting earlier may help limit losses. No backtest, performance evidence, transaction costs, or method for establishing that the pair remains suitable is provided.

Key ideas

  • A pairs signal can be built from the log ratio of the two asset prices.
  • Use a moving average and moving standard deviation of that ratio to define relative extremes.
  • At an upper threshold, the example buys one asset and sells the other; at a lower threshold, it reverses the trade.
  • The suggested exit occurs when the ratio returns to its moving average, though earlier exits are possible.
  • Lookback, threshold, exit rule, position sizing, and pair selection all affect the method.

Tags

Full text
# pairs trading algorithm with returns


# pairs trading algorithm with returns












I'm having a difficulty grasping how to write a pair algorithm using returns instead of prices.

With price differences, I have the mean difference over a long time period. When the current price difference moves away from the mean I open a position. When it moves back to the mean I close then position.

With returns, I have the mean difference in returns between two stocks. What am I looking to move away from this mean? Is it just when a single period returns deviates? If so, when do I close.

A single day may be above the mean so I open. It should come back, but how do I know when its happened? If the next day is below the mean I dont think its time to close. It just working back down, but still pay not be all the way back.

## Answer by mark leeds (score 1)

https://quant.stackexchange.com/a/51742

Hi Don: The following is a very standard approach. It's basically the use of Bollinger Bands on the log ratio of the two prices.

So, say one stock is y and the other stock is x. Denote the prices as $P_y$ and $P_x$.

Then, you do the following.

1) Keep calculating the moving average of $log(\frac{P_y}{P_x})$ over time along with the moving standard deviation of the same thing.

2) When $log(\frac{P_y}{P_x})$ is $ 2 \sigma$ above the moving average, you go long y and you go short x. When it's $2 \sigma$ below the moving average, you go short y and go long x.

Note that 2) is really what technicians use in Bollinger Bands except that it's on the log price ratio rather than the log price.

3) Exit the position when the log price ratio returns to the moving average.

There are many parameters that you can experiment with:

A) the window size of the moving average in days or hours or minutes or whatever.

B) the scale factor that multiplies sigma. It doesn't have to be 2.

C) Exit rule. You don't have to wait until you return to the moving average. In fact, it could pay to get out earlier than that in order to avoid large losses.

D) Letting position size be proportional to how strong the reversion is.

Obviously, the pairs you use are key to the whole thing and figuring those out is kind of seperate from the step described above. I hope this helped some.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.