Skip to main content
Log in

A Finite Difference Scheme for Pairs Trading with Transaction Costs

  • Published:
Computational Economics Aims and scope Submit manuscript

Abstract

We consider a pairs trading stochastic control problem with transaction costs and constraints on the gross market exposure, and propose a new monotone Finite Difference scheme approximating the viscosity solution of the Hamilton–Jacobi–Bellman equation characterizing the optimal trading strategies. Given a fixed time horizon and a portfolio of two cointegrated assets, the agent trades the spread between the two assets and the trading strategy is defined as the possibly negative portfolio weight maximizing the expected exponential utility derived from terminal wealth. Furthermore, trades incur transaction costs comprised of explicit transactions fees and commissions and the implicit cost due to slippage. These costs are modeled as a linear or square root function of the trading rate and respectively added or subtracted from the observable asset price at the time when a buy or a sell order enters the market. Our main contribution is the derivation of a robust approximation for the nonlinear transaction cost term in the Hamilton–Jacobi–Bellman equation. Finally, we combine our monotone Finite Difference scheme with a Monte Carlo sampling method to analyze the effects of transaction fees and slippage on the trading policies’ performance.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10

Similar content being viewed by others

References

  • Almgren, R. (2003). Optimal execution with nonlinear impact functions and trading-enhanced risk. Applied Mathematical Finance, 10(1), 1–18. https://doi.org/10.1080/135048602100056.

    Article  Google Scholar 

  • Almgren, R., & Chriss, N. (2001). Optimal execution of portfolio transactions. Journal of Risk, 3, 5–40.

    Article  Google Scholar 

  • Almgren, R., Thum, C., Hauptmann, E., & Li, H. (2005). Direct estimation of equity market impact. Risk, 18, 57–62.

    Google Scholar 

  • Angoshtari, B. (2016, August). On the Market-Neutrality of Optimal Pairs-Trading Strategies (Papers No. 1608.08268). arXiv.org. Retrieved from https://ideas.repec.org/p/arx/papers/1608.08268.html.

  • Barles, G., Daher, C., & Romano, M. (1995). Convergence of numerical schemes for parabolic equations arising in finance theory. Mathematical Models and Methods in Applied Sciences, 5, 125–143.

    Article  Google Scholar 

  • Barles, G., & Souganidis, P. (1991). Convergence of approximation schemes for fully nonlinear second order equations. Asymptotic Analysis, 4, 271–283.

    Article  Google Scholar 

  • Benth, F. E., & Karlsen, K. H. (2005). A note on Merton’s portfolio selection problem for the Schwartz mean-reversion model. Stochastic Analysis and Applications, 23, 687–704.

    Article  Google Scholar 

  • Chiu, M. C., & Wong, H. Y. (2011). Mean. variance portfolio selection of cointegrated assets. Journal of Economic Dynamics and Control, 35, 1369–1385.

    Article  Google Scholar 

  • Cuoco, D. (1997). Optimal consumption and equilibrium prices with portfolio constraints and stochastic income. Journal of Economic Theory, 72, 33–73.

    Article  Google Scholar 

  • Curato, G., Gatheral, J., & Lillo, F. (2017). Optimal execution with nonlinear transient market impact. Quantitative Finance, 17(1), 41–54. https://doi.org/10.1080/14697688.2016.1181274.

    Article  Google Scholar 

  • Cvitanic, J., & Karatzas, I. (1992). Convex duality in constrained portfolio optimization. The Annals of Applied Probability, 2(4), 767–818.

    Article  Google Scholar 

  • Duan, J.-C., & Pliska, S. (2004). Option valuation with co-integrated asset prices. Journal of Economic Dynamics and Control, 28, 727–754.

    Article  Google Scholar 

  • Fleming, W. H., & Soner, H. M. (1993). Controlled Markov processes and viscosity solutions. Berlin: Springer.

    Google Scholar 

  • Gatheral, J. (2010). No-dynamic-arbitrage and market impact. Quantitative Finance, 10(7), 749–759.

    Article  Google Scholar 

  • Grossman, S., & Vila, J.-L. (1992). Optimal dynamic trading with leverage constraints. The Journal of Financial and Quantitative Analysis, 27(2), 151–168.

    Article  Google Scholar 

  • Guasoni, P., & Weber, M. (2015). Nonlinear price impact and portfolio choice. Retrieved from. https://doi.org/10.2139/ssrn.2613284.

  • Hogan, S., Jarrow, R., Teoc, M., & Warachkac, M. (2004). Testing market efficiency using statistical arbitrage with applications to momentum and value strategies. Journal of Financial Economics, 73, 525–565.

    Article  Google Scholar 

  • Kogan, L., & Uppal, R. (2002). Risk aversion and optimal portfolio policies in partial and general equilibrium economies (Tech. Rep. No. 3306). Centre for Economic Policy Research. (Discussion Paper)

  • Lei, Y., & Xu, J. (2015). Costly arbitrage through pairs trading. Journal of Economic Dynamics and Control, 56, 1–19.

    Article  Google Scholar 

  • Leung, T., & Li, X. (2015). Optimal mean reversion trading with transaction costs and stop-loss exit. International Journal of Theoretical and Applied Finance, 18(3), 1550020.

    Article  Google Scholar 

  • Lillo, F. (2003). Master curve for price-impact function. Nature, 421, 129–130.

    Article  Google Scholar 

  • Liu, R., Muhler-Karbe, J., & Weber, M. (2017). Rebalancing with linear and quadratic costs. SIAM Journal on Control and Optimization, 55(6), 3533–3563.

    Article  Google Scholar 

  • Mudchanatongsuk, S., Primbs, J. A., & Wong, W. (2008). Optimal pairs trading: A stochastic control approach. In Proceedings of the American control conference (pp. 1035–1039).

  • Ngo, M.-M., & Pham, H. (2014). Optimal switching for pairs trading rule: a viscosity solutions approach. Retrieved from http://arxiv.org/pdf/1412.7649v1.pdf.

  • Pham, H. (2009). Continuous-time stochastic control and optimization with financial applications. Berlin: Springer.

    Book  Google Scholar 

  • Potters, M., & Bouchaud, J.-P. (2002). More statistical properties of order books and price impact. Physica A: Statistical Mechanics and its Applications, 324, 133–140.

    Article  Google Scholar 

  • Primbs, J. . A., & Yamada, Y. (2018). Pairs trading under transaction costs using model predictive control. Quantitative Finance, 18(6), 885–895. https://doi.org/10.1080/14697688.2017.1374549.

    Article  Google Scholar 

  • Rouy, E., & Tourin, A. (1992). A viscosity solutions approach to shape-fromshading. SIAM Journal on Numerical Analysis, 29(3), 867–884.

    Article  Google Scholar 

  • Soner, H. M. (1986a). Optimal control with state-space constraint. I. SIAM Journal on Control and Optimization, 24, 552–561.

    Article  Google Scholar 

  • Soner, H. M. (1986b). Optimal control with state-space constraint. II. SIAM Journal on Control and Optimization, 24, 1110–1122.

    Article  Google Scholar 

  • Tourin, A., & Yan, R. (2013). Dynamic pairs trading using the stochastic control approach. Journal of Economic Dynamics and Control, 37(10), 1972–1981.

    Article  Google Scholar 

  • Touzi, N. (2013). Optimal stochastic control, stochastic target problems, and backward SDE. Berlin: Springer.

    Book  Google Scholar 

Download references

Acknowledgements

The Authors have contributed equally to this paper.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Agnès Tourin.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix: The Finite Difference Scheme for the model with price impact

Appendix: The Finite Difference Scheme for the model with price impact

In this appendix, we derive a monotone approximation for the viscosity solution of (68), (69). We will use the standard notations

$$\begin{aligned} D_z^+G_{i,j}^n&= \frac{G_{i+1,j}^n-G_{i,j}^n}{\varDelta z},&D_z^-G_{i,j}^n&= \frac{G_{i,j}^n-G_{i-1,j}^n}{\varDelta z},\\ D_{\pi }^+G_{i,j}^n&= \frac{G_{i,j+1}^n-G_{i,j}^n}{\varDelta \pi },&D_{\pi }^-G_{i,j}^n&= \frac{G_{i,j}^n-G_{i,j-1}^n}{\varDelta \pi },\\ D_{z}^+D_z^-G_{i,j}^n&= \frac{G_{i+1,j}^n-2G_{i,j}^n+G_{i-1,j}^n}{(\varDelta z)^2}. \end{aligned}$$

As in Sect. 5, we split (68) into two operators:

$$\begin{aligned} g_{\tau } -a(z,\pi )g - b(z,\pi ) g_z - \frac{1}{2}\sigma _{\beta }^2 g_{zz} =0, \end{aligned}$$
(70)

and

$$\begin{aligned} g_{\tau }+\sup \limits _{v\in A}\big \{ -\gamma \lambda v^2 g +\kappa \gamma \pi vg - \kappa vg_z - vg_{\pi } \big \}=0. \end{aligned}$$
(71)

Next, we proceed as in Sect. 5 to derive a scheme for (71) in the interior of the domain by writing

$$\begin{aligned}&\frac{G_{i,j}^{n+1}-G_{i,j}^n}{\varDelta t}\nonumber \\&\quad =\min (\inf _{b_{i,j}+\kappa v>=0, v>=0} \{(a_{i,j}-\kappa \gamma \pi _j v+\lambda \gamma v^2)G_{i,j}^n+(b_{i,j}+\kappa v)D_z^+G_{i,j}^n+\frac{1}{2}\sigma _{\beta }^2D_{z}^+D_z^-G_{i,j}^n+vD_{\pi }^+G_{i,j}^n\},\nonumber \\&\quad \inf _{b_{i,j}+\kappa v>=0, v<0} \{(a_{i,j}-\kappa \gamma \pi _j v+\lambda \gamma v^2)G_{i,j}^n+(b_{i,j}+\kappa v)D_z^+G_{i,j}^n+\frac{1}{2}\sigma _{\beta }^2D_z^+D_z^-G_{i,j}^n+vD_{\pi }^-G_{i,j}^n\},\nonumber \\&\quad \inf _{b_{i,j}+\kappa v<0, v>=0} \{(a_{i,j}-\kappa \gamma \pi _j v+\lambda \gamma v^2)G_{i,j}^n+(b_{i,j}+\kappa v)D_z^-G_{i,j}^n+\frac{1}{2}\sigma _{\beta }^2D_z^+D_z^-G_{i,j}^n+vD_{\pi }^+G_{i,j}^n\},\nonumber \\&\quad \inf _{b_{i,j}+\kappa v<0, v<0} \{(a_{i,j}-\kappa \gamma \pi _j v+\lambda \gamma v^2)G_{i,j}^n+(b_{i,j}+\kappa v)D_z^-G_{i,j}^n+\frac{1}{2}\sigma _{\beta }^2D_z^+D_z^-G_{i,j}^n+vD_{\pi }^-G_{i,j}^n\}). \end{aligned}$$
(72)

We can solve the above optimization problem in closed form.

  • For the first infimum, the critical point is

    $$\begin{aligned} v^{++} = \frac{\kappa \gamma \pi _j G_{i,j}^n-\kappa D_z^+G_{i,j}^n-D_{\pi }^+G_{i,j}^n}{2\lambda \gamma G_{i,j}^n}. \end{aligned}$$

    The infimum is attained at \(v_1^*\) defined by

    • if \(b_{i,j}+\kappa v \ge 0, v \ge 0\), \(v_1^*=v^{++}\)

    • if \(b_{i,j}+\kappa v \ge 0, v < 0\), \(v_1^*=0\)

    • if \(b_{i,j}+\kappa v < 0, v \ge 0\), \(v_1^*=-\frac{b_{i,j}}{\kappa }\).

  • For the second infimum, the critical point is

    $$\begin{aligned} v^{+-} = \frac{\kappa \gamma \pi _j G_{i,j}^n-\kappa D_z^+G_{i,j}^n-D_{\pi }^-G_{i,j}^n}{2\lambda \gamma G_{i,j}^n}. \end{aligned}$$

    The solution of the minimization problem is given by

    • if \(b_{i,j}+\kappa v \ge 0, v < 0\), \(v_2^*=v^{+-}\)

    • if \(b_{i,j}+\kappa v \ge 0, v \ge 0\), \(v_2^*=0\)

    • if \(b_{i,j}+\kappa v< 0, v < 0\), \(v_2^*=-\frac{b_{i,j}}{\kappa }\).

  • For the third infimum, the critical point is

    $$v^{-+} = \frac{\kappa \gamma \pi _j G_{i,j}^n-\kappa D_z^-G_{i,j}^n-D_{\pi }^+G_{i,j}^n}{2\lambda \gamma G_{i,j}^n},$$

    and the solution of the optimization problem is

    • if \(b_{i,j}+\kappa v < 0, v \ge 0\), \(v_3^*=v^{-+}\)

    • if \(b_{i,j}+\kappa v< 0, v < 0\), \(v_3^*=0\)

    • if \(b_{i,j}+\kappa v \ge 0, v \ge 0\), \(v_3^*=-\frac{b_{i,j}}{\kappa }\)

  • Finally, for the forth infimum, the critical point is

    $$\begin{aligned} v^{--} = \frac{\kappa \gamma \pi _j G_{i,j}^n-\kappa D_z^-G_{i,j}^n-D_{\pi }^-G_{i,j}^n}{2\lambda \gamma G_{i,j}^n}, \end{aligned}$$

    and the solution of the minimization problem is given by

    • if \(b_{i,j}+\kappa v< 0, v < 0\), \(v_4^*=v^{--}\)

    • if \(b_{i,j}+\kappa v < 0, v \ge 0\), \(v_4^*=0\)

    • if \(b_{i,j}+\kappa v \ge 0, v < 0\), \(v_4^*=-\frac{b_{i,j}}{\kappa }\)

For instance, when the minimum in (72) is realized for the first infimum and achieved at the critical point inside the interval, the resulting Finite Difference scheme is given by

$$\begin{aligned} G_{i,j}^{n+1}= & {} =1+\varDelta t[\frac{1}{2}\sigma _{\beta }^2 D^+_z D^-_z G_{i,j}^n+ (b_{i,j}+\frac{\kappa ^2\pi _j}{2\lambda })D^+_z G_{i,j}^n\nonumber \\&-\frac{\kappa ^2}{4\lambda \gamma G_{i,j}^n}(D^+_z G_{i,j}^n)^2 +\frac{\kappa }{2\lambda }\pi _j D^+_{\pi } G_{i,j}^n+(a_{i,j}\nonumber \\&-\frac{\kappa ^2\gamma }{4\lambda }\pi _j^ 2) G_{i,j}^n-\frac{\kappa }{2\lambda \gamma }\frac{D^+_z G_{i,j}^n D^+_{\pi } G_{i,j}^n}{G_{i,j}^n} -\frac{1}{4\lambda \gamma }\frac{(D^+_{\pi } G_{i,j}^n)^2}{G_{i,j}^n}]. \end{aligned}$$
(73)

When, the minimum is realized for one of the other infima and achieved inside the associated interval, on must replace in the above scheme the forward Finite Differences \(D^+_z G_{i,j}^n\) and \(D^+_{\pi } G_{i,j}^n\) by the appropriate pair of Finite Differences, which are respectively \(D^+_z G_{i,j}^n, D^-_{\pi } G_{i,j}^n\) for the second infimum, \(D^-_z G_{i,j}^n, D^+_{\pi } G_{i,j}^n\) for the third, and \(D^-_z G_{i,j}^n, D^-_{\pi } G_{i,j}^n\) for the forth.

When the minimum holds for \(v^*=0\), (73) degenerates to

$$\begin{aligned} G_{i,j}^{n+1}= & {} =G_{i,j}^n. \end{aligned}$$
(74)

Finally, we leave to the reader the case when \(v^*=-\frac{b_{i,j}}{\kappa }\).

Note that, as in Sect. 5, we also need to modify the scheme to accommodate the state constraint at the edges \(\pi _{{\min }}\) and \(\pi _{{\max }}\). We leave this straightforward modification to the reader as well.

Since (73) is explicit, the scheme is only convergent under the following CFL condition derived from verifying the monotonicity condition.

$$\begin{aligned}&1+\varDelta t (a_{i,j}-\frac{\kappa ^2\pi _j^2\gamma }{4\lambda }-\frac{\sigma _{\beta }^2}{\varDelta z^2}-\frac{(b_{i,j}+\frac{\kappa ^2\pi _j}{2\lambda })}{\varDelta z} -\frac{\kappa \pi _j}{2\lambda \varDelta \pi }-\frac{\kappa }{2\lambda \gamma \varDelta \pi \varDelta z}\frac{(G_{i,j}^n)^2-G_{i+1,j}^n G_{i,j+1}^n}{(G_{i,j}^n)^2}\nonumber \\&\quad +\frac{\kappa ^2}{4\lambda \gamma \varDelta z^2}\frac{(G_{i+1,j}^n)^2-(G_{i,j}^n)^2}{(G_{i,j}^n)^2}+\frac{1}{4\lambda \gamma \varDelta \pi ^2}\frac{(G_{i,j+1}^n)^2-(G_{i,j}^n)^2}{(G_{i,j}^n)^2} ) \ge 0,\nonumber \\&\quad {\text{ for all}} \; i,j. \end{aligned}$$
(75)

Note that when other combinations of the forward and backward Finite Differences arise at the minimum, we need to modify (75) accordingly. Since these changes are straightforward, we leave them to the reader.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Li, Z., Tourin, A. A Finite Difference Scheme for Pairs Trading with Transaction Costs. Comput Econ 60, 601–632 (2022). https://doi.org/10.1007/s10614-021-10159-w

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10614-021-10159-w

Keywords

Navigation