Skip to content

Login / Register

Backtesting

This guide covers how to backtest a pairs strategy to see if the model's indicators would have made or lost money in the past. This is also known as paper-trading. The web app will create virtual positions and trade against historical data as though the data feed were live. This way, you can "replay" a strategy over time to see whether it would have made or lost money.

 

The Pairs Trader Web App allows you to:

  • Set position entry / exit triggers for the backtest
  • Set trade conditions that must be met before a position is taken
  • See the results for every pair in the application
  • Drill down into position-level details
  • Chart the results

 

Set triggers

A trigger is something that causes a historical simulated position to be put on. This is your primary trading indicator. It is required and can be either the Pair Index or the Z-Scored Pair Index.

(click for larger view)

Pair Index is specified as the deviation from 100, the base value of the index. For  example if you require an entry threshold of 5 and an exit threshold of 2, positions will only be taken when Pair Index rises above 105 or below 95. The position will subsequently be closed out when it falls to within 98 - 102. The signal is naturally mean-reverting.

Z-Scored Pair Index is similiar, except the entry / exit indicator thresholds are interpreted as standard deviations on the normal distribution, not Pair Index deviations from 100. For example if you require an entry threshold of 2 and an exit threshold of 1, positions will be only taken when Pair Index is at least 2 standard deviations above the mean or at least 2 standard deviations below the mean (the mean is calculated as the 60-day moving average on Pair Index). If Pair Index is normally distributed, these outcomes are observed with a 5% probability. The position will be subsequently closed when the z-score falls to within 1 standard deviation of the 60-day moving average. These outcomes occur with 68% probability on the normal distribution.

The normal distribution looks like:

(click for Wikipedia article)

A word of caution: the Z-Scored Pair Index is usually very useful for backtesting. However, interpretting standard deviations as probabilities on the normal distribution will vary from pair to pair because only certain pairs will have a normally-distributed Pair Index. These are the pairs that are mostly likely to have an actual statistical relationship, meaning they are cointegrated.

 

Set trade conditions

A condition is optional. Turn conditions on or off by checking the checkbox next to each condition name. When turned on, these conditions are required to be met before making the trade. If the trigger signal indicates a position should be opened but one or more trade conditions are not met, for example, the position will not be opened. Setting more conditions makes the backtest inherently more conservative.

Conditions are very helpful to control various scenarios. For example, you may find large jumps in Pair Index indicate momentum in either leg of the stock, or a decoupling of business models between the firms. If such decoupling is present, reversal speed and correlation are likely to go down. Setting conditions for reversal speed and correlation and making these values high will make the strategy more conservative and should help avoid trading in situations where the stocks are becoming decoupled.

 

Position capital

This is the capital applied to each position. Dollar and percentage returns are based on this number. You should set this number to an amount you typically trade with per position.

 

See the results

Once you run a backtest you can see aggregate P&L and return, and best, worst and average trade statistics for every pair you have downloaded in the web app.

(click for larger view)

Click any row to bring up a detailed list of positions.

 

Drill down into results

Simply click any position to get a detailed view of various conditions and trigger values at the time the position was entered and exited. This way you can refine your backtest to eliminate poor positions and keep the good ones.

(click for larger view)

 

Plot the results

After you run a backtest the results will automatically be charted. Simply fip back to your Pair Index Chart tab.

Green highlights are periods in which the strategy made money; red highlights are periods in which it lost money. Hover your mouse over a particular period to see the dollar and percentage returns and the description of the trade.

(click for larger view)

To turn off backtest highlighting simply uncheck the "Show Backtested Positions" checkbox.

 

glqxz9283 sfy39587p08