# Pair Trading Models

From Pair Trading Lab WIKI

Pair Trading Lab offers pair trading algorithms based on various mathematical models. These are models currently supported in PTL:

## Ratio Model

This is one of the standard pair trading models described in literature. It is based in ratio of instrument prices, moving average and standard deviation. In other words, it is based on Bollinger Bands indicator.

Model parameters:

- entry threshold E
_{n}for Z-score, typical value range is <1.5, 2.5>, 2.0 is used most often - exit threshold E
_{x}for Z-score, typical value is <-0.5, 0.5>, 0 is used most often - max Z-score E
_{max}(optional, to filter out extremes, typical value is >4 if used) - moving average period P
_{m}(typical range <10, 100>), default = 15 - moving average type T (algorithm), default = exponential
- standard deviation period P
_{s}(typical range <10, 100>), default = 15 - entry mode (simple, uptick, downtick)

Model support:

- in PTL backtester:
**yes** - in PTL portfolio backtester:
**yes** - in PTL Trader:
**yes**

Description:

- we trade pair of stocks A, B, having price series
*A(t)*,*B(t)* - we need to calculate ratio time series
*R(t)*=*A(t)*/*B(t)* - let's apply moving average of type T with period P
_{m}on*R(t)*to get time series*M(t)* - let's apply standard deviation with period P
_{s}on*R(t)*to get time series*S(t)* - now we can create Z-score series
*Z(t)*as*Z(t)*= (*R(t)*-*M(t)*) /*S(t)*, this time series can give us z-score to signal trading decision directly - another common approach (to visualize) is to create bands and put it above the moving average
*M(t)*:- upper entry band
*U*=_{n}(t)*M(t)*+*S(t)** E_{n} - lower entry band
*L*=_{n}(t)*M(t)*-*S(t)** E_{n} - upper exit band
*U*=_{x}(t)*M(t)*+*S(t)** E_{x} - lower exit band
*L*=_{x}(t)*M(t)*-*S(t)** E_{x} - these bands are actually the same bands as in Bollinger Bands indicator and we can use crossing of
*R(t)*and bands as trade signals

- upper entry band