PAIRS TRADING: AN OPTIMAL SELLING RULE

. Pairs trading involves two cointegrated securities. When diver-gence is underway, i.e., one stock moves up while the other moves down, a pairs trade is entered consisting of a short position in the outperforming stock and a long position in the underperforming one. Such a strategy bets the “spread” between the two would eventually converge. This paper is concerned with an optimal pairs-trade selling rule. In this paper, a diﬀerence of the pair is governed by a mean-reverting model. The trade will be closed whenever the diﬀerence reaches a target level or a cutloss limit. Given a ﬁxed cutloss level, the objective is to determine the optimal target so as to maximize an overall return. This optimization problem is related to an optimal stopping problem as the cutloss level vanishes. Expected holding time and proﬁt probability are also obtained. Numerical examples are reported to demonstrate the results. 91G80; Secondary: 49L20.


1.
Introduction. The idea of pairs trading is to select and monitor a pair of cointegrated stocks; see Gatev et al. [5] and Liu and Timmermann [8] for related discussions. When the spread of the stock prices increases to a certain level, the pairs trade would be triggered: to short the stronger stock and to long the weaker one betting the eventual convergence of the spread. The idea of pairs trading was introduced by Bamberger and followed by Tartaglia's quantitative group at Morgan Stanley in the 1980s. The most attractive feature of pairs trading is its 'market neutral' nature in the sense that it can be profitable under any market conditions. For related literature and detailed discussions on the subject, we refer the reader to the paper by Gatev et al. [5], the book by Vidyamurthy [9], and references therein.
In this paper, we focus on when to exit a pairs position assuming the entry of a pairs position is triggered when the spread reaches two standard deviations as in [5]. Our objective is to identify the optimal threshold levels determining when to sell (close) the pairs position. In particular, we make a selling decision when either the spread reaches a target or a pre-determined cutloss level, whichever comes first. Given the cutloss level. the goal is to decide when to lock in profits if the pairs performs as expected. The main purpose of this paper is to focus on the mathematics of selling the pairs position. In particular, we consider the case when a 'normalized' difference of a pair satisfies a mean reversion model, solve a differential equation with two point boundaries, and obtain the corresponding optimality.
Mean-reversion models are one of the popular choices in financial markets to capture price movements that have the tendency to move towards an "equilibrium" level. We refer the reader to Cowles and Jones [2], Fama and French [3], and Gallagher and Taylor [4] among others for studies in connection with mean reversion stock returns. See also Hafner and Herwartz [7] for mean-reversion stochastic volatility and Blanco and Soronow [1] for asset prices in energy markets.
Mathematical selling rules have been studied for many years. For example, Zhang [10] considered a selling rule determined by two threshold levels: a target price and a cutloss limit. In [10], such optimal threshold levels are obtained by solving a set of two-point boundary value problems. Guo and Zhang [6] studied the optimal selling rule under a model with switching geometric Brownian motion. Using a smooth-fit technique, they obtained the optimal threshold levels by solving a set of algebraic equations. Note that these papers are only concerned with geometric Brownian motion type models.
In equity investment, when to cut losses is the most challenging part of trading. In practice, there are many scenarios where cutting losses may arise. A typical one is a margin call. When the pairs position undergoes heavy losses, a margin call may be triggered so that part of or the entire position must be closed to meet the margin requirement. In addition, cointegrated pairs may cease to be cointegrated at some point, for example in an acquisition (or bankruptcy) of one stock in the pairs position. In this case, it is necessary to enforce a pre-determined cutloss rule and exit the entire position.
In this paper, we consider a selling rule when the spread reaches either a target or a given cutloss level. The objective is to determine the optimal target level. We first obtain a differential equation with two point boundaries, then solve this equation and obtain the best target level. We also compare our results with the traditional optimal stopping approach and show that as the cutloss level vanishes, our optimal target is identical to selling threshold of the associated optimal stopping problem. In addition, we obtain the expected holding time and profit probability. We also examine the dependence of these quantities on various parameters in a numerical example. Finally, we demonstrate how to implement the results using a pair of stocks.
This paper is organized as follows. In §2, we formulate the pairs selling problem under consideration. In §3, we study the optimal selling rule and obtain near equivalence with the corresponding optimal stopping problem. In §4, we obtain expected holding time and profit probability. Numerical examples are considered in §5.
2. Problem formulation. In this paper, we consider pairs trading that involves two stocks X 1 and X 2 . The pairs position consists of a long position in X 1 and short position in X 2 . Let X 1 t and X 2 t denote their respective prices at time t ≥ 0. For simplicity, we allow trading a fraction of a share and consider the pairs position consisting of K 1 = 1/X 1 0 shares of X 1 in the long position and K 2 = 1/X 2 0 shares of X 2 in the short position. The corresponding price of the position is given by We assume that Z t is a mean-reverting (Ornstein-Uhlenbeck) process governed by where a > 0 is the rate of reversion, b the equilibrium level, σ > 0 the volatility, and W t a standard Brownian motion. In addition, the notation Z represents the corresponding pairs position. One share long in Z means the combination of K 1 shares of long position in X 1 and K 2 shares of short position in X 2 . Similarly, for i = 1, 2, X i t represents the price of stock X i . Lastly, Z t is the value of the pairs position at time t (which in this paper is allowed to be negative).

Remark 1.
Here, for convenience, the initial value Z 0 = z is not limited to be zero and can take any value in IR. In addition, assuming two standard derivation entry rule, we require Assuming a pairs position was in place, the objective is to decide when to close the position. We consider the selling rule determined by two threshold levels: the target and a cutloss level. In particular, let z 1 denote the cutloss level and z 2 the target. The selling time is given by the exit time τ of Z t from (z 1 , z 2 ), i.e., τ = inf{t : Z t ∈ (z 1 , z 2 )}.
In Gatev et al. [5], the threshold levels z 1 = −∞ and z 2 = b are used to determine when to close a pairs position. Note that in practice a cutloss level is often imposed to limit possible undesirable events in the marketplace. It is a typical money management consideration. It can also be associated with a margin call due to substantial losses.
Given the initial state Z 0 = z, the corresponding reward function is Here ρ > 0 is a given discount (impatience) factor.

Remark 2.
In mean reversion models with b = 0, a useful concept in connection with the rate of reversion is half life, which is the time required for Z t to change from z 0 to z 0 /2. In practical literature the value (ln 2)/a is often used to represent such quantity. Note that the half life τ should be a stopping time. We can relate τ with (ln 2)/a as follows: Solve the equation (1) in terms of W t : Take t = τ . Then Z τ = z 0 /2. Taking expectations of both sides, we have Ee aτ = 2. Using Jensen's inequality, we have e aEτ ≤ Ee aτ = 2. Therefore Eτ ≤ (ln 2)/a, i.e., the expected half life is typically smaller than (ln 2)/a.  In this example, we use 3000 daily closing prices of X 1 =WMT and X 2 =TGT (from 2001/01/25 to 2012/12/31). In Figure 1, the process .86 is plotted. In addition, the entire data is divided into two equal halves. The first half is used to calibrate the model and the second half to backtest our results.
To estimate parameters a, b, and σ, note that, for any 0 ≤ t 0 ≤ t, we have We discretize this equation with step size δ and obtain It is easy to see that ε n ∼ N (0, In view of this, Z nδ is an autoregressive process of order 1. Following standard AR(1) estimation (least square) method, we obtain the estimates for α, β, and Σ, which lead to a = 1.0987, b = −0.2288, and σ = 0.2669.
3. An optimal selling rule. Following a similar approach as in Zhang [10], we can show the reward function v(z) satisfies the two-point-boundary-value differential equation Then the general solution of (3) can be given in terms of a linear combination of independent solutions: for some constants C 1 and C 2 Note that these constants are (z 1 , z 2 ) dependent, i.e., C 1 = C 1 (z 1 , z 2 ) and C 2 = C 2 (z 1 , z 2 ).
Taking z = z 1 and z = z 2 respectively, we have Let Φ(z 1 , z 2 ) denote the above 2 × 2 matrix. We claim that this matrix is nonsingular. In fact, let Then it is easy to see that φ(x) is strictly increasing in x. Therefore, On the other hand we have which is strictly less than zero. Therefore Φ(z 1 , z 2 ) is invertible and the constants C 1 and C 2 can be expressed in terms of z 1 and z 2 as follows: Given the initial value Z 0 = z, the corresponding reward function The optimization problem is to choose z 2 ≥ z to maximize v(z).
A 'nearly' equivalent optimal stopping problem. In this section we consider a related optimal stopping problem. Full details of the description and treatment of this section can be obtained following the step-by-step approach in [11]. Let F t = σ{Z r : r ≤ t} and τ be an F t stopping time. The problem is to choose τ to maximize J(z, τ ) = E[e −ρτ Z τ |Z 0 = z]. Let V (z) denote the corresponding reward function, i.e., V (z) = sup τ J(z, τ ). Then, the associated Hamilton-Jacobi-Bellman equation is given by To solve this equation, we first consider ρV (z) − AV (z) = 0, where Its general solution is given by for some constants A 1 and A 2 . Suggested by the results in [11], we expect this solution to be bounded. In addition, ρV − AV = 0 is expected to hold on (−∞, z * ) for some z * and V = z on (z * , ∞). In view of this, A 2 must be equal to zero. Furthermore, the solution to (4) should be continuously differentiable. The smoothfit conditions demand We show next that this equation has a unique solution z * > 0. In fact, let Then it is easy to see that φ(z) > 0 for z < 0, and its derivative is It follows that φ(z) is strictly decreasing on (0, ∞) and φ (z) → −∞, as z → ∞. Therefore, φ(z) must have a unique zero z * > 0. Again, following a similar argument as in [11], we can show that the optimal selling point is τ * = inf{t : Z t ≥ z * }. The corresponding reward function is Returning to our (z 1 , z 2 )-optimization problem, intuitively as z 1 → −∞ (or when the cutloss is removed), the (z 1 , z 2 )-optimization problem should be equivalent to the the above optimal stopping problem. It can be shown by direct computation This function reaches its maximum at z 2 = z * , which recovers the value function for the optimal stopping problem.
Remark 3. Let τ = T be a deterministic selling time. Then J(z, τ ) = J(z, T ) = e −ρT E(Z T ) → 0 as T → ∞. It follows that V (z) = sup τ J(z, τ ) ≥ lim T →∞ J(z, T ) = 0. In addition, let θ = inf{t ≥ 0 : Z t ≥ z * }. Then it can be shown as in [11] that P (θ < ∞) = 1. That is, any target level z * is reachable in finite time. Therefore, in order to have nonnegative V (z), one must have z * ≥ 0. Of course, the holding time tends to get longer to reach z * , especially when b is very negative. This tendency can be seen from Table 4 in §5.
In view of the above comparison, it is clear that the (z 1 , z 2 )-optimization problem is more intuitive and easier to work with. In addition, it is also easier to compute the expected holding time and corresponding profit probability. These are the subjects of the next section.
4. Expected holding time and profit probability. First we consider the expected holding time. For each Z 0 = z, let τ = τ (z) = inf{t ≥ 0 : Z t ∈ (z 1 , z 2 )} and T (z) = E[τ |Z 0 = z]. Then T (z) satisfies the differential equation: where T is the derivative of T . Integrate both sides to obtain where T 0 is a constant. Using the boundary conditions T (z 1 ) = T (z 2 ) = 0 and integrating both sides again, we have Given the initial Z 0 = z 0 , let τ 0 = τ (z 0 ). Then the expected holding time is given by Eτ 0 = T (z 0 ).
Next we consider the profit probability. Given Z 0 = z, the profit probability P (z) is defined as the conditional probability of Z t reaching z 2 before hitting z 1 . Therefore, P (z) satisfies the differential equation: Solving this equation we have With Z 0 = z 0 , the corresponding profit probability
The entry of the pairs position is triggered when the spread is two standard deviations, i.e., z 0 = b − 2σ Z = −0.59.

Remark 4.
Recall that the cutloss level in this paper is a pre-determined risk level and our objective is to choose z 2 to maximize the corresponding reward function. Alternatively, one may consider the optimization over both variables z 1 and z 2 simultaneously. For example, let us consider the optimization over (z 1 , z 2 ) ∈ [−1.60, −0.90] × [0, 0.50]. It can be seen following simple numerical computation that the optimal (z * 1 , z * 2 ) = (−1.60, 0.14), which shows that the optimal z * 1 takes the lowest value of its given interval. This is true in general due to our mean reversion formulation. In view of this, it is natural to focus on z 2 with z 1 given.
In this section, we take 14. The corresponding expected holding time is Eτ 0 = 11.74 and profit probability is P 0 = 0.999981. Note that the profit probability is overwhelming in the mean reversion case. It is probably meaningful only when comparing with related cases because the model is only an approximation to the market and may never be as precise.
Next, we vary one of the parameters at a time and examine the dependence on these parameters.
Dependence of (z 2 , Eτ 0 , P 0 ) on parameters. First we consider the values of (z 2 , Eτ 0 , P 0 ) associated with varying a. A larger a leads to a greater pulling force back to the equilibrium b. It can be seen in Table 1 that the target level z 2 decreases as a increases. Also the expected holding time Eτ 0 shrinks while the profit probability P 0 increases in a. The selling level z 2 decreases which suggests one should take profit sooner as a gets bigger because the potential of going higher becomes smaller.  Table 1. z 2 , Eτ 0 , P 0 with varying a. In Table 2 we vary the volatility σ. By and large, the volatility is the source forcing the price to go away from its equilibrium. The large the σ, the farther the price fluctuates, so is the target level z 2 . The expected holding time decreases because the target is more reachable. This leads to increases in profit probability.  Table 2. z 2 , Eτ 0 , P 0 with varying σ. Next, we vary the discount rate ρ. Larger ρ means quicker profits. This is confirmed in Table 3. It shows that larger ρ leads to a smaller target z 2 , shorter holding time, and larger profit probability. This means more buying opportunities and quicker profit taking.  Table 3. z 2 , Eτ 0 , P 0 with varying ρ. In Table 4, we vary the mean b. It can be seen in this case, a smaller b lower the equilibrium, which pushes down the target z 2 , which remains above zero. In the meantime, smaller b leads to large gap between b and its target, which leads in turn increasing expected holding time Eτ 0 and smaller profit probability P 0 .  Table 4. z 2 , Eτ 0 , P 0 with varying b. Finally, instead of having z 0 = b − 2σ Z = −0.59, we vary its value around z 0 = −0.59. As can be seen in Table 5, the target z 2 is not z 0 dependent. In addition, smaller z 0 leads to increasing Eτ 0 and smaller profit probability P 0 . z 0 -0.39 -0.49 -0.59 -0.69 -0.79 z 2 0.14 0.14 0.14 0.14 0.14 Eτ 0 11.09 11.39 11.73 11.82 11.98 P 0 0.999983 0.999982 0.999981 0.999979 0.999976 Table 5. z 2 , Eτ 0 , P 0 with varying z 0 .
Remark 5. Recall that in Gatev et al. [5], the corresponding z 1 = −∞ and z 2 = b. Clearly, the choice of z 2 = b is far from being optimal. On the other hand, notice the symmetry of (Z t − b). When following the same two standard deviation entry rule, the opposite trade should be opened (i.e., short X 1 and long X 2 ) when Z t > b + 2σ Z , which forces the previous pairs position to be closed. In view of this, z 2 should satisfy the constraint z 2 ≤ b + 2σ Z . Clearly, the above constraint on z 2 does not hold automatically. In our base case, z * 2 = 0.14 and b + 2σ Z = 0.13. To follow the same entry rule, we truncate the target level and use min{z 2 , b + 2σ Z } instead in our backtesting example.
Backtesting (WMT-TGT). In this section, we backtest the pairs selling rule using the stock prices of WMT and TGT from 2001 to 2012. Let X 1 t and X 2 t be the daily closing prices of WMT and TGT stocks, respectively. The initial prices on 2001/01/25 are X 1 0 = 44.84 and X 2 0 = 31.86. The corresponding Z t = X 1 t /44.84 − X 2 t /31.86. Using the parameters obtained in Example 1 based on the historical prices from 2001 to 2007, we obtained the target levels in Table 3. Note that b + 2σ Z = 0.13. We use min{z 2 , b + 2σ Z } as the target in lieu of z 2 . In addition, we follow the two standard deviation entry rule, i.e., open the position whenever Z 0 = z 0 ≤ b − 2σ Z = −0.59. This occurred on 2007/1/17 and the daily closing prices were 42.34 for WMT and 55.82 for TGT.
Suppose we trade with an account with the capital $10K and allocate equal amounts to long and short positions. At the closing of 1/17, we buy 118 shares of WMT at $42.25 and short 91 shares of TGT at $54.65. Next, we exit the pairs position when either Z t reaches the target z 2 or the cutloss level z 1 = −1.31, whichever comes first.
In Table 6 Table 6. Testing Results with Different Choices for ρ. In Figure 2, the range from the target levels are marked together with entry level z 0 and cutloss level z 1 .