Optimal Mean Reversion Trading with Transaction Costs and Stop-Loss Exit
Tim Leung, Xin Li
Introduction
It has been widely observed that many asset prices exhibit mean reversion, including commodities (see Schwartz (1997)), foreign exchange rates (see Engel and Hamilton (1989); Anthony and MacDonald (1998); Larsen and Sørensen (2007)), as well as US and global equities (see Poterba and Summers (1988); Malliaropulos and Priestley (1999); Balvers et al. (2000); Gropp (2004)). Mean-reverting processes are also used to model the dynamics of interest rate, volatility, and default risk. In industry, hedge fund managers and investors often attempt to construct mean-reverting prices by simultaneously taking positions in two highly correlated or co-moving assets. The advent of exchange-traded funds (ETFs) has further facilitated this pairs trading approach since some ETFs are designed to track identical or similar indexes and assets. For instance, Triantafyllopoulos and Montana (2011) investigate the mean-reverting spreads between commodity ETFs and design model for statistical arbitrage. Dunis et al. (2013) also examine the mean-reverting spread between physical gold and gold equity ETFs.
Given the price dynamics of some risky asset(s), one important problem commonly faced by individual and institutional investors is to determine when to open and close a position. While observing the prevailing market prices, a speculative investor can choose to enter the market immediately or wait for a future opportunity. After completing the first trade, the investor will need to decide when is best to close the position. This motivates the investigation of the optimal sequential timing of trades.
In this paper, we study the optimal timing of trades subject to transaction costs under the Ornstein-Uhlenbeck (OU) model. Specifically, our formulation leads to an optimal double stopping problem that gives the optimal entry and exit decision rules. We obtain analytic solutions for both the entry and exit problems. In addition, we incorporate a stop-loss constraint to our trading problem. We find that a higher stop-loss level induces the investor to voluntarily liquidate earlier at a lower take-profit level. Moreover, the entry region is characterized by a bounded price interval that lies strictly above stop-loss level. In other words, it is optimal to wait if the current price is too high or too close to the lower stop-loss level. This is intuitive since entering the market close to stop-loss implies a high chance of exiting at a loss afterwards. As a result, the delay region (complement of the entry region) is disconnected. Furthermore, we show that optimal liquidation level decreases with the stop-loss level until they coincide, in which case immediate liquidation is optimal at all price levels.
A typical solution approach for optimal stopping problems driven by diffusion involves the analytical and numerical studies of the associated free boundary problems or variational inequalities (VIs); see e.g. Bensoussan and Lions (1982), Øksendal (2003), and Sun (1992). For our double optimal stopping problem, this method would determine the value functions from a pair of VIs and require regularity conditions to guarantee that the solutions to the VIs indeed correspond to the optimal stopping problems. As noted by Dayanik (2008), “the variational methods become challenging when the form of the reward function and/or the dynamics of the diffusion obscure the shape of the optimal continuation region.” In our optimal entry timing problem, the reward function involves the value function from the exit timing problem, which is not monotone and can be positive and negative.
In contrast to the variational inequality approach, our proposed methodology starts with a characterization of the value functions as the smallest concave majorant of any given reward function. A key feature of this approach is that it allows us to directly construct the value function, without a priori finding a candidate value function or imposing conditions on the stopping and delay (continuation) regions, such as whether they are connected or not. In other words, our method will derive the structure of the stopping and delay regions as an output.
Our main results provide the analytic expressions for the value functions of the double stopping problems; see Theorems 4.2 and 4.5 (without stop-loss), and Theorems 5.1 and 5.5 (with stop-loss). In earlier studies, Dynkin and Yushkevich (1969) analyze the concave characterization of excessive functions for a standard Brownian motion, and Dayanik and Karatzas (2003) and Dayanik (2008) apply this idea to study the optimal single stopping of a one-dimensional diffusion. In this regard, we contribute to this line of work by solving a number of optimal double stopping problems with and without a stop-loss exit under the OU model.
Among other related studies, Ekstrom et al. (2011) analyze the optimal single liquidation timing under the OU model with zero long-run mean and no transaction cost. The current paper extends their model in a number of ways. First, we analyze the optimal entry timing as well as the optimal liquidation timing. Our model allows for a non-zero long-run mean and transaction costs, along with a stop-loss level. Song et al. (2009) propose a numerical stochastic approximation scheme to solve for the optimal buy-low-sell-high strategies over a finite horizon. Under a similar setting, Zhang and Zhang (2008) and Kong and Zhang (2010) also investigate the infinite sequential buying and selling/shorting problem under exponential OU price dynamics with slippage cost.
In the context of pairs trading, a number of studies have also considered market timing strategy with two price levels. For example, Gatev et al. (2006) study the historical returns from the buy-low-sell-high strategy where the entry/exit levels are set as 1 standard deviation from the long-run mean. Similarly, Avellaneda and Lee (2010) consider starting and ending a pairs trade based on the spread’s distance from its mean. In Elliott et al. (2005), the market entry timing is modeled by the first passage time of an OU process, followed by an exit at a fixed finite horizon. In comparison, rather than assigning ad hoc price levels or fixed trading times, our approach will generate the entry and exit thresholds as solutions of an optimal double stopping problem. Considering an exponential OU asset price with zero mean, Bertram (2010) numerically computes the optimal enter and exit levels that maximize the expected return per unit time. Gregory et al. (2010) also apply this approach to log-spread following the CIR and GARCH diffusion models. Other timing strategies adopted by practitioners have been discussed in Vidyamurthy (2004).
On the other hand, the related problem of constructing portfolios and hedging with mean reverting asset prices has been studied. For example, Benth and Karlsen (2005) study the utility maximization problem that involves dynamically trading an exponential OU underlying asset. Jurek and Yang (2007) analyze a finite-horizon portfolio optimization problem with an OU asset subject to the power utility and Epstein-Zin recursive utility. Chiu and Wong (2012) consider the dynamic trading of co-integrated assets with a mean-variance criterion. Tourin and Yan (2013) derive the dynamic trading strategy for two co-integrated stocks in order to maximize the expected terminal utility of wealth over a fixed horizon. They simplify the associated Hamilton-Jacobi-Bellman equation and obtain a closed-form solution. In the stochastic control approach, incorporating transaction costs and stop-loss exit can potentially limit model tractability and is not implemented in these studies.
The rest of the paper is structured as follows. We formulate the optimal trading problem in Section 2, followed by a discussion on our method of solution in Section 3. In Section 4, we analytically solve the optimal double stopping problem and examine the optimal entry and exit strategies. In Section 5, we study the trading problem with a stop-loss constraint. The proofs of all lemmas are provided in the Appendix.
Problem Overview
Let us discuss a pairs trading example where we model the value of the resulting position by an OU process. The primary objective is to motivate our trading problem, rather than proposing new estimation methodologies or empirical studies on pairs trading. For related studies and more details, we refer to the seminal paper by Engle and Granger (1987), the books Hamilton (1994); Tsay (2005), and references therein.
We construct a portfolio by holding shares of a risky asset and shorting shares of another risky asset , yielding a portfolio value at time . The pair of assets are selected to form a mean-reverting portfolio value. In addition, one can adjust the strategy to enhance the level of mean reversion. For the purpose of testing mean reversion, only the ratio between and matters, so we can keep constant while varying without loss of generality. For every strategy , we observe the resulting portfolio values realized over an -day period. We then apply the method of maximum likelihood estimation (MLE) to fit the observed portfolio values to an OU process and determine the model parameters. Under the OU model, the conditional probability density of at time given at with time increment is given by
Using the observed values , we maximize the average log-likelihood defined by
In Figure 1, we illustrate an example based on two pairs of exchange-traded funds (ETFs), namely, the Market Vectors Gold Miners (GDX) and iShares Silver Trust (SLV) against the SPDR Gold Trust (GLD) respectively. These liquidly traded funds aim to track the price movements of the NYSE Arca Gold Miners Index (GDX), silver (SLV), and gold bullion (GLD) respectively. These ETF pairs are also used in Triantafyllopoulos and Montana (2011) and Dunis et al. (2013) for their statistical and empirical studies on ETF pairs trading.
2 Optimal Stopping Problem
Given that a price process or portfolio value evolves according to an OU process, our main objective is to study the optimal timing to open and subsequently close the position subject to transaction costs. This leads to the analysis of an optimal double stopping problem.
From the investor’s viewpoint, represents the expected liquidation value associated with . On the other hand, the current price plus the transaction cost constitute the total cost to enter the trade. The investor can always choose the optimal timing to start the trade, or not to enter at all. This leads us to analyze the entry timing inherent in the trading problem. Precisely, we solve
As extension, we can incorporate a stop-loss level of the pairs trade, that caps the maximum loss. In practice, the stop-loss level may be exogenously imposed by the manager of a trading desk. In effect, if the price ever reaches level prior to the investor’s voluntary liquidation time, then the position will be closed immediately. The stop-loss signal is given by the first passage time
Therefore, we determine the entry and liquidation timing from the constrained optimal stopping problem:
Due to the additional timing constraint, the investor may be forced to exit early at the stop-loss level for any given liquidation level. Hence, the stop-loss constraint reduces the value functions, and precisely we deduce that and . As we will show in Sections 4 and 5, the optimal timing strategies with and without stop-loss are quite different.
Method of Solution
In this section, we disucss our method of solution. First, we denote the infinitesimal generator of the OU process by
and recall the classical solutions of the differential equation
Direct differentiation yields that , , and . Hence, we observe that both and are strictly positive and convex, and they are, respectively, strictly increasing and decreasing.
Define the first passage time of to some level by . As is well known, and admit the probabilistic expressions (see Itō and McKean (1965) and Rogers and Williams (2000)):
A key step of our solution method involves the transformation
where , , and
The candidate optimal exit interval is determined by maximizing the expectation in (3.7). This is equivalent to maximizing (3.10) over and in the transformed problem. This leads to
This is the smallest concave majorant of . Applying the definition of to (3.10), we can express the maximal expected discounted reward as
If , then we have and a.s. In effect, this removes the lower exit level, and the corresponding expected discounted reward is
Consequently, by considering interval-type strategies, we also include the class of stopping strategies of reaching a single upper level (see Theorem 4.2 below).
Next, we prove the optimality of the proposed stopping strategy and provide an expression for the value function.
The value function defined in (2.3) is given by
where , and are defined in (3.4), (3.6) and (3.12), respectively.
The proof is provided in Appendix A.1. Let us emphasize that the optimal levels may depend on the initial value , and can potentially coincide, or take values and . As such, the structure of the stopping and delay regions can potentially be characterized by multiple intervals, leading to disconnected delay regions (see Theorem 5.5 below).
We follow the procedure for Theorem 3.2 to derive the expression for the value function in (2.4). First, we denote and (see (3.3)–(3.4)), with discount rate . In addition, we define the transformation
Using these functions, we consider the function analogous to :
Following the steps (3.7)–(3.12) with , , , and replaced by , , , and , respectively, we write down the smallest concave majorant of , namely,
From this, we seek to determine the candidate optimal entry interval in the coordinate. Following the proof of Theorem 3.2 with the new functions , , , , and , the value function of the optimal entry timing problem admits the expression
An alternative way to solve for and is to look for the solutions to the pair of variational inequalities
Analytical Results
We will first study the optimal exit timing in Section 4.1, followed by the optimal entry timing problem in Section 4.2.
We now analyze the optimal exit timing problem (2.3). In preparation for the next result, we summarize the crucial properties of .
The function is continuous on , twice differentiable on and possesses the following properties:
Let be the unique solution to . Then, we have
Based on Lemma 4.1, we sketch in Figure 2. The properties of are essential in deriving the value function and optimal liquidation level, as we show next.
The optimal liquidation problem (2.3) admits the solution
where the optimal liquidation level is found from the equation
and is bounded below by . The corresponding optimal liquidation time is given by
Proof. From Lemma 4.1 and the fact that as (see also Figure 2), we infer that there exists a unique number such that
In turn, the smallest concave majorant is given by
Substituting into (4.5), we have the LHS
Equivalently, we can express condition (4.5) in terms of :
In turn, we obtain the value function by substituting (4.8) into (3.13).
Next, we examine the dependence of the investor’s optimal timing strategy on the transaction cost .
Since , (see (3.3)), and according to Theorem 4.2, we conclude that is increasing in .
In other words, if the transaction cost is high, the investor would tend to liquidate at a higher level, in order to compensate the loss on transaction cost. For other parameters, such as and , the dependence of is generally not monotone.
2 Optimal Entry Timing
Having solved for the optimal exit timing, we now turn to the optimal entry timing problem. In this case, the value function is
To solve for the optimal entry threshold(s), we will need several properties of , as we summarize below.
The function is continuous on , differentiable on , and twice differentiable on , and possesses the following properties:
. Let denote the unique solution to , then and
is strictly decreasing if .
Let denote the unique solution to , then and
In Figure 3, we give a sketch of according to Lemma 4.4. This will be useful for deriving the optimal entry level.
The optimal entry timing problem (2.4) admits the solution
where the optimal entry level is found from the equation
Proof. We look for the value function of the form: , where is the the smallest concave majorant of . From Lemma 4.4 and Figure 3, we infer that there exists a unique number such that
Substituting into (4.12), we have
which is equivalent to condition (4.11). Furthermore, using (3.14) and (3.15), we get
To conclude, we substitute of (4.14) and of (3.15) into of (4.13), which by (3.16) yields the value function in (4.10).
With the analytic solutions for and , we can verify by direct substitution that in (4.2) and in (4.10) satisfy both (3.17) and (3.18).
Since the optimal entry timing problem is nested with another optimal stopping problem, the parameter dependence of the optimal entry level is complicated. Below, we illustrate the impact of transaction cost.
The optimal entry level of (2.4) is decreasing in the transaction cost .
Proof. Considering the optimal entry level as a function of , we differentiate (4.11) w.r.t. to get
Since and , the sign of is determined by . Denote . Recall that ,
and smooth pastes at . Since both and are positive decreasing convex functions, it follows that . Observing that and , we have . Applying this to (4.15), we conclude that .
We end this section with a special example in the OU model with no mean reversion.
If we set in (2.1), with and fixed, it follows that reduces to a Brownian motion: , . In this case, the optimal liquidation level for problem (2.3) is
and the optimal entry level for problem (2.4) is the root to the equation
Incorporating Stop-Loss Exit
Now we consider the optimal entry and exit problems with a stop-loss constraint. For convenience, we restate the value functions from (2.5) and (2.6):
After solving for the optimal timing strategies, we will also examine the dependence of the optimal liquidation threshold on the stop-loss level .
We first give an analytic solution to the optimal exit timing problem.
The optimal liquidation problem (5.2) with stop-loss level admits the solution
The optimal liquidation level is found from the equation
Proof. Due to the stop-loss level , we consider the smallest concave majorant of , denoted by , over the restricted domain and set for .
In turn, the smallest concave majorant admits the form:
Substituting into (5.6), we have from the LHS
Therefore, we can equivalently express (5.6) in terms of :
which by rearrangement immediately simplifies to (5.5).
Furthermore, for , implies that
Substituting this to , the value function becomes
which resembles (5.3) after the observation that
The direct effect of a stop-loss exit constraint is forced liquidation whenever the price process reaches before the upper liquidation level . Interestingly, there is an additional indirect effect: a higher stop-loss level will induce the investor to voluntarily liquidate earlier at a lower take-profit level.
The optimal liquidation level of (5.2) strictly decreases as the stop-loss level increases.
Figure 5 illustrates the optimal exit price level as a function of the stop-loss levels , for different long-run means . When is strictly greater than (on the left of the straight line), the delay region is non-empty. As increases, strictly decreases and the two meet at (on the straight line), and the delay region vanishes.
as long as These results (5.9) and (5.10) also hold in the case without stop-loss.
2 Optimal Entry Timing
and look for non-trivial optimal timing strategies.
Associated with reward function from entering the market, we define the function as in (3.11) whose properties are summarized in the following lemma.
The function is continuous on , differentiable on , twice differentiable on , and possesses the following properties:
. for .
is strictly decreasing for .
There exists some constant such that , and
In addition, , where .
The optimal entry timing problem (5.1) admits the solution
where the critical levels and satisfy, respectively,
Proof. We look for the value function of the form: where is the smallest non-negative concave majorant of . From Lemma 5.4 and the sketch of in Figure 6, the maximizer of , , satisfies
Also there exists a unique number such that
In turn, the smallest non-negative concave majorant admits the form:
Substituting into (5.18), we have
Equivalently, we can express condition (5.18) in terms of :
Simplifying this shows that solves (5.15). Also, we can express in terms of :
In addition, substituting into (5.17), we have
which, after a straightforward simplification, is identical to (5.16). Also, can be written as
Substituting these to , we arrive at (5.12).
Theorem 5.5 reveals that the optimal entry region is characterized by a price interval strictly above the stop-loss level and strictly below the optimal exit level . In particular, if the current asset price is between and , then it is optimal for the investor to wait even though the price is low. This is intuitive because if the entry price is too close to , then the investor is very likely to be forced to exit at a loss afterwards. As a consequence, the investor’s delay region, where she would wait to enter the market, is disconnected.
Figure 7 illustrates two simulated paths and the associated exercise times. We have chosen to be 2 standard deviations below the long-run mean , with other parameters from our pairs trading example. By Theorem 5.5, the investor will enter the market at (see (5.14)). Since both paths start with , the investor waits to enter until the OU path reaches from above, as indicated by in panels (a) and (b). After entry, Figure 7 describes the scenario where the investor exits voluntarily at the optimal level , whereas in Figure 7 the investor is forced to exit at the stop-loss level . These optimal levels are calculated from Theorem 5.5 and Theorem 5.1 based on the given estimated parameters.
We remark that the optimal levels , and are outputs of the models, depending on the parameters and the choice of stop-loss level . Recall that our model parameters are estimated based on the likelihood maximizing portfolio discussed in Section 2.1. Other estimation methodologies and price data can be used, and may lead to different portfolio strategies and estimated parameters values . In turn, the resulting optimal entry and exit thresholds may also change accordingly.
3 Relative Stop-Loss Exit
4 Concluding Remarks
Other extensions include adapting our double optimal stopping problem to the exponential OU, Cox-Ingorsoll-Ross (CIR), or other underlying dynamics, and to countable number of trades (Zervos et al., 2013; Zhang and Zhang, 2008). Alternatively, one can model asset prices by specifying the dynamics of the dividend stream. For instance, Scheinkman and Xiong (2003) study the optimal timing to trade between two speculative traders with different beliefs on the mean-reverting (OU) dividend dynamics. Other than trading of risky assets, it is also useful to study the timing to buy/sell derivatives written on a mean-reverting underlying (see e.g. Leung and Liu (2012) and Leung and Shirai (2013)). For all these applications, it is natural to examine the optimal stopping problems over a finite horizon although explicit solutions are less available.
Appendix A Appendix
A.1 Proof of Theorem 3.2 (Optimality of ).
where follows from the martingale property of and .
By (A.2) and the fact that majorizes , it follows that
Maximizing (A.3) over all and yields that .
A.2 Proof of Lemma 4.1 (Properties of ). The continuity and twice differentiability of on follow directly from those of , and . To show the continuity of at , since , we only need to show that . Note that , as . Therefore,
We conclude that is also continuous at .
Since both and are positive, we only need to determine the sign of .
Define . is the intersecting point at axis of the tangent line of . Since is a positive, strictly decreasing and convex function, is strictly increasing and as . Also, note that
Therefore, there exists a unique root that solves , and , such that
Thus is strictly decreasing if , and increasing otherwise.
Since and are all positive, we only need to determine the sign of :
Therefore, is convex if , and concave otherwise.
A.3 Proof of Lemma 4.4 (Properties of ). We first show that and are twice differentiable everywhere, except for . Recall that
which implies that Therefore, is differentiable everywhere and so is . However, is not twice differentiable since
and . Consequently, is not twice differentiable at .
The twice differentiability of and are straightforward. The continuity and differentiability of on and twice differentiability on follow directly. Observing that as , is also continuous at by definition. We now establish the properties of .
(i) First we prove the value of at :
(ii) With , for ,
since , , and . Therefore, is strictly decreasing for .
Since , and are all positive, we only need to determine the sign of :
To determine the sign of in , first note that is a strictly increasing function in , since is a strictly increasing function and by assumption. Next note that for ,
Also, note that as . Therefore, if and if with being the break-even point. From this, we conclude property (iii).
A.4 Proof of Lemma 5.4 (Properties of ). (i) The continuity of on is implied by the continuities of , and . The continuity of at follows from
where we have used that as .
Furthermore, for , we have , and thus, . Also, with the facts that is a strictly increasing function and , property (i) follows.
(ii) By the definition of , since and are differentiable everywhere, we only need to show the differentiability of . To this end, is differentiable at by (5.3)-(5.5), but not at . Therefore, is differentiable for .
In view of the facts that , , and , we have for ,
Therefore, is strictly decreasing for .
(iii) Both and are twice differentiable everywhere, while is twice differentiable everywhere except at and , and so is . Therefore, is twice differentiable on .
To determine the convexity/concavity of , we look at the second order derivative:
This implies that is convex for .
Furthermore, if is strictly increasing on , then is also strictly increasing. To prove this, we first recall from Lemma 4.1 that is strictly increasing and concave on . By Proposition 5.3, we have , which implies , and thus, .
Then, it follows from (4.5), (4.6) and (5.7) that for . Next, since , we have
The same holds for with replacing . As both and are positive, is equivalent to . This implies that
since , , and . Recalling that , we have established that is a strictly increasing function, and so is . As we have shown the existence of an interval over which is concave, or equivalently with . Then by the strictly increasing property of , we conclude and is the unique solution to , and
Hence, we conclude the convexity and concavity of the function .