Backtesting a Pair Trading Strategy

A pairs trading strategy involves answering these questions:

  1. How do you identify “stocks that move together?”
  2. Should they be in the same industry?
  3. How far should they have to diverge before you enter the trade?
  4. When is a position unwound?

We saw how to answer the first two questions: understanding, defining, finding, and investigating pairs.

Trading strategy

We can start with a simple trading strategy: we buy the spread if it is one standard deviation below the average and sell the spread if its is one standard deviation above the average.

To keep things simple, we’ll ignore execution details like lot-size, actual $ p&l, etc… and focus on the viability of the strategy. We calculate p&l in terms of unit-spread, i.e., how many ‘spreads’ of p&l did the strategy create?

For BANKNIFTY vs. ICICIBANK, we simulated the strategy outlined above based on the daily close of the nearest to expiry futures from Jan-2010:

BANKNIFTY - ICICIBANK pair trade backtest 50 2010-01-01 long-short

The top chart is the the spread.
The 2nd is the trade: green implies the strategy went long the spread, red implies short.
The 3rd chart indicates the p&l of that specific trade (in spreads).
The last chart indicates the cumulative p&l (in spreads).
 
The p&l for this strategy over the entire time-period is +69.3189 spreads.

Asymmetric strategy

The idea behind the above strategy is to bet on mean-reversion on both sides. However, if you see closely, the shorts were not nearly as profitable as the longs. You could be better off just going long the spread whenever it hit one standard deviation and staying out of the market when the spread hit the upper band.

BANKNIFTY vs. ICICIBANK, long-only p&l +454.3036:

BANKNIFTY - ICICIBANK pair trade backtest 50 2010-01-01 long only

BANKNIFTY vs. HDFCBANK, long-only p&l +231.5225:

BANKNIFTY - HDFCBANK pair trade backtest 50 2010-01-01 long only

Conclusion

Some caveats:

  1. The signals are intermittent, but you need to keep running the algorithms everyday to capture the alpha. This requires an investment in systems on your part.
  2. The backtest ignores execution risk. For example, the hedge ratio is around 0.09830581 and there’s no way you can trade 1/10th of a contract. So your actual executable spread = 10 ICICIBANK – BANKNIFTY. That’s 11 contacts and it still doesn’t give you precision.

On the plus side:

  1. The backtest doesn’t do any risk management. This would’ve stop-loss’ed most of the bad trades.
  2. There is money to be made on the right pairs.

Comments are closed, but trackbacks and pingbacks are open.