Skip to main content
Log in

Portfolio construction as linearly constrained separable optimization

  • Research Article
  • Published:
Optimization and Engineering Aims and scope Submit manuscript

Abstract

Mean–variance portfolio optimization problems often involve separable nonconvex terms, including penalties on capital gains, integer share constraints, and minimum nonzero position and trade sizes. We propose a heuristic algorithm for such problems based on the alternating direction method of multipliers (ADMM). This method allows for solve times in tens to hundreds of milliseconds with around 1000 securities and 100 risk factors. We also obtain a bound on the achievable performance. Our heuristic and bound are both derived from similar results for other optimization problems with a separable objective and affine equality constraints. We discuss a concrete implementation in the case where the separable terms in the objective are piecewise quadratic, and we empirically demonstrate its effectiveness for tax-aware portfolio construction.

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

Similar content being viewed by others

References

  • Bertsekas D (1999) Nonlinear programming, 3rd edn. Athena Scientifc, Nashua

    MATH  Google Scholar 

  • Benidis K, Feng Y, Palomar D (2018) Optimization methods for financial index tracking: from theory to practice. Found Trends Optim 3(3):171–279

    Article  MATH  Google Scholar 

  • Boyd S, Busseti E, Diamond S, Kahn R, Nystrup P, Speth J (2017) Multi-Period Trading via Convex Optimization. Found Trends Optim 3(1):1–76

    Article  Google Scholar 

  • Boyd S, Parikh N, Chu E (2011) Distributed optimization and statistical learning via the alternating direction method of multipliers. Found Trends Mach Learn 3(1):1–122

    Article  MATH  Google Scholar 

  • Boyd S, Vandenberghe L (2004) Convex optimization. Cambridge University Press, Cambridge

    Book  MATH  Google Scholar 

  • Grinold R, Kahn R (1999) Active Portfolio management, 2nd edn. McGraw-Hill, New York

    Google Scholar 

  • Gardiner B, Lucet Y (2010) Convex hull algorithms for piecewise linear-quadratic functions in computational convex analysis. Set-Valued Var Anal 18(3–4):467–482

    Article  MathSciNet  MATH  Google Scholar 

  • Lobo M, Fazel M, Boyd S (2007) Portfolio optimization with linear and fixed transaction costs. Ann Oper Res 152(1):341–365

    Article  MathSciNet  MATH  Google Scholar 

  • Markowitz H (1952) Portfolio selection. J Finance 7(1):7791

    Google Scholar 

  • Markowitz H (1955) The optimization of a quadratic function subject to linear constraints. RAND Corporation Tech rep, Santa Monica

    Google Scholar 

  • Moehle N, Kochenderfer MJ, Boyd S, Ang A (2021) Tax-aware portfolio construction via convex optimization. J Optim Theory Appl 189(2):364–383

    Article  MathSciNet  MATH  Google Scholar 

  • Mansini R, Ogryczak W, Speranza MG (2015) Linear and mixed integer programming for portfolio optimization. Springer, Cham

    Book  MATH  Google Scholar 

  • Rockafellar R (1970) Convex analysis. Princeton University Press, Princeton

    Book  MATH  Google Scholar 

  • Sharpe W (1963) A simplifed model for portfolio analysis. Manag Sci 9(2):277293

    Google Scholar 

  • Stellato B, Banjac G, Goulart P, Bemporad A, Boyd S (2020) OSQP: an operator splitting solver for quadratic programs. Math Program Comput 12:637–672

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nicholas Moehle.

Additional information

Publisher's Note

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

Appendices

Appendix A Portfolio construction parameters

We can convert problem (7) into the separable–affine form (5). The variable is \(x = (h, c, y)\in \textbf{R}^{l+k+1}\). The affine constraint parameters are

$$\begin{aligned} A = \begin{bmatrix} C^TX &{} 0 &{} -I \\ \textbf{1}^T &{} 1 &{} 0 \end{bmatrix}, \qquad b = \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \end{aligned}$$

The part of the separable function corresponding to asset i is

$$\begin{aligned} f_i(h_i) = \alpha _ih_i - \gamma ^{\textrm{risk}}D_{ii} h_i^2 + \gamma ^{\textrm{trd}} \phi ^{\textrm{trd}}_i(h_i - h^{\textrm{init}}_i) + \gamma ^{\textrm{hld}} \phi ^{\textrm{hld}}_i(h_i) \end{aligned}$$

for \(i = 1,\dots , l\). The component of f corresponding to c is

$$\begin{aligned} f_{l+1}(c) = {\left\{ \begin{array}{ll} 0 &{} \text {if } 1 - \eta ^{\textrm{ub}} \le c \le 1 - \eta ^{\textrm{lb}} \\ \infty &{} \text {otherwise.} \end{array}\right. } \end{aligned}$$

The component of f corresponding to y is \(f_i(y_i) = y_i^2\), for \(i = l+2,\dots , l+k+1\).

Appendix B Convex envelope details

We can compute the convex envelope of a piecewise quadratic function as discussed in Sect. 6.3. To do this, we must compute the parameters \(\alpha \), \(\beta \), \(x_\varphi \), and \(x_\psi \) from (19). We do this making use of the following two facts.

The first fact is that candidate values of \(\alpha \), \(\beta \), \(x_\varphi \), and \(x_\psi \) are valid if and only if the function \(\alpha x + \beta \) is tangent to \(\psi ^i\) at \(x_\psi \) and to \(\varphi _i\) at \(x_\varphi \). This holds if and only if

$$\begin{aligned} \alpha \in \partial \psi ^i(x_\psi ), \quad \psi ^i(x_\psi ) = \alpha x_\psi + \beta , \quad \alpha \in \partial \varphi _i(x_\varphi ), \quad \varphi _i(x_\varphi ) = \alpha x_\psi + \beta , \end{aligned}$$
(20)

where \(\partial \psi ^i\) and \(\partial \varphi _i\) are the subdifferentials of \(\psi ^i\) and \(\varphi _i\). These conditions can be easily checked given a set of candidate parameters \(\alpha \), \(\beta \), \(x_\psi \), and \(x_\varphi \).

The second fact is that (19) can be rewritten

$$\begin{aligned} \psi ^{i+1}(x) = \min \{\psi ^i, \varphi _i\}^{**} = {\left\{ \begin{array}{ll} \psi _1^i(x) &{} \text {if } x \in [{\tilde{a}}_1, {\tilde{b}}_1] \\ \qquad \qquad \vdots &{} \qquad \qquad \vdots \\ \psi _{j-1}^i(x) &{} \text {if } x \in [{\tilde{a}}_{j-1}, {\tilde{b}}_{j-1}] \\ \min \{\psi _j^i, \varphi _i \}^{**} &{} \text {if } x \in [{\tilde{a}}_j, b_i], \\ \end{array}\right. } \end{aligned}$$
(21)

where \({\tilde{a}}_1 \le {\tilde{b}}_i \le \dots \le {\tilde{a}}_j\) are the endpoints of the pieces of \(\psi ^i\). In other words, the function \(\psi ^{i+1}\) matches \(\psi ^i\) up to the jth piece of \(\psi ^i\), and after that, is equal to the convex envelope of the pointwise minimum of \(\psi ^i_j\) and \(\varphi _i\). This convex envelope (the last piece in (21)) is easy to compute, as \(\min \{\psi _j^i, \varphi _i\}\) is a piecewise quadratic with two pieces. (We discuss how to do this in Sect. 1.)

This means that once j is known, we can use (21) to compute \(\psi ^{i+1}\). To find j, we simply try all pieces of \(\psi ^i\), compute the right-hand side of (21), and check if the resulting parameters \(\alpha \), \(\beta \), \(x_\psi \) and \(x_\varphi \) satisfy the conditions (20).

1.1 Appendix B.1 Piecewise-quadratic functions with two pieces

The function \(\min \{\psi _j^i, \varphi _i\}\) in (21) is piecewise quadratic with two pieces. Here we discuss how to compute the convex envelope of such functions.

Let g(x) be a PWQ with two pieces: \(g_1(x) = p_1x^2 + q_1x + r_1\) on \([a_1, b_1]\), and \(g_2(x) = p_2x^2 + q_2x + r_2\) on \([a_2, b_2]\), with \(b_1 \le a_2\). In this case, \(g^{**}\) has the form

$$\begin{aligned} g^{**}(x) = {\left\{ \begin{array}{ll} g_1(x) &{} \text {if } x \in [a_1, x_1]\\ h(x) = \alpha x + \beta &{} \text {if } x \in [x_1, x_2]\\ g_2(x) &{} \text {if } x \in [x_2, b_2] \end{array}\right. } \end{aligned}$$
(22)

for some \(\alpha \), \(\beta \), \(x_1\), and \(x_2\). These parameters are real valued, but we allow for the case when \(x_1 = -\infty \) or \(x_2 = \infty \); in these cases, first or last interval is degenerate, and can be ignored.

Similarly to (20) above, it is necessary and sufficient for the parameters \(\alpha \), \(\beta \), \(x_1\), and \(x_2\) to satisfy

$$\begin{aligned} \alpha \in \partial g_1(x_1), \quad g_1(x_1) = \alpha x_1 + \beta , \quad \alpha \in \partial g_2(x_2), \quad g_2(x_2) = \alpha x_2 + \beta . \end{aligned}$$
(23)

How these checks are carried out in practice depends on whether \(x_1\) (or \(x_2\)) are in the interior or boundary of the domain of \(g_1\) (or \(g_2\)), or whether \(x_1 = -\infty \) (or \(x_2 = \infty \)).

1.1.1 Appendix B.1.1 The midpoint-to-midpoint case

We first consider the case when \(x_1\) is in the interior of the domain of \(g_1\), i.e., \(a_1< x_1 < b_1\), and \(x_2\) is in the interior of the domain of g, i.e., \(a_2< x_2 < b_2\). In this case, we must have

$$\begin{aligned} g_1(x_1) = h(x_1), \quad g_2(x_2) = h(x_2), \quad g_1'(x_1) = h(x_1), \quad g_2'(x_2) = h(x_2). \end{aligned}$$
(24)

By plugging in the values of the functions and their derivatives, we obtain

$$\begin{aligned} \begin{aligned} p_1x_1^2 + q_1x_1 + r_1&= \alpha x_1 + \beta \\ p_2x_2^2 + q_2x_2 + r_2&= \alpha x_2 + \beta \\ 2p_1x_1 + q_1&= \alpha \\ 2p_2x_2 + q_1&= \alpha . \\ \end{aligned} \end{aligned}$$
(25)

These four equations can be reduced to a single quadratic equation with a single unknown. This quadratic equation has at most two solutions, each corresponding to a set of candidate values of \(\alpha \), \(\beta \), \(x_1\), and \(x_2\). To see if these candidate values \(\alpha \), \(\beta \), \(x_1\), and \(x_2\) parameterize a valid convex envelope of g, we check if our initial assumption, that \(a_1< x_1 < b_1\) and \(a_2< x_2 < b_2\), holds.

1.1.2 Appendix B.1.2 The midpoint-to-endpoint case

Now we consider the case in which \(x_1\) is in the interior of the domain of \(g_1\), and \(x_2 \in \{a_2, b_2\}\). (We note that the case in which \(x_1 \in \{a_1, b_1\}\) and \(x_2\) in the interior of the domain of g can be handled similarly, and we do not discuss it further.)

Finite upper bound. We start with the case when \(x_2 < \infty \). To do this, we solve a slightly modified set of equations:

$$\begin{aligned} g_1(x_1) = h(x_1), \quad g_1'(x_1) = h'(x_1), \quad g_2(x_2) = h(x_2). \end{aligned}$$
(26)

These are the first three equations of (25). As before, they can be reduced to a single quadratic equation with a single unknown. This quadratic equation has at most two solutions, each corresponding to a set of candidate values of \(\alpha \), \(\beta \), and \(x_1\).

To see if these candidate values parameterize a valid convex envelope, we verify that \(x_1\) is in the interior of the domain of \(g_1\), i.e., \(a_1< x_1 < b_1\), and also the second condition of (23). In the degenerate case in which \(g_2\) is defined over a single point, i.e., \(a_2 = b_2\), this second condition always holds; in the non-degenerate case \(a_2 < b_2\), the condition is equivalent to \(g_2'(x_2) = 2p_2x_2 + q_2 \le \alpha \) if \(x_2 = a_2\), and \(g_2'(x_2) = 2p_2x_2 + q_2 \ge \alpha \) if \(x_2 = b_2\).

Infinite upper bound. Next we consider the case of \(x_2 = \infty \), which may occur when \(x_2 = b_2 = \infty \), i.e., the domain of \(g_2\) is unbounded. In this case, we modify the last equation in (26), resulting in the equations

$$\begin{aligned} g_1(x_1) = h(x_1), \quad g_1'(x_1) = h'(x_1), \quad g_2'(\infty ) = h'(\infty ). \end{aligned}$$
(27)

The last equation is equivalent to \(p_2 = 0\) and \(\alpha = q_2\). To find the corresponding candidate values of \(\beta \), and \(x_1\), we solve \(g_1(x_1) = h(x_1)\) and \(g_1'(x_1) = h'(x_1)\). To check the validity of the candidate values of \(\alpha \), \(\beta \), \(x_1\), and \(x_2\), we check that \(a_1< x_1 < b_1\) and \(p_2 = 0\).

1.1.3 Appendix B.1.3 The endpoint-to-endpoint case

Finally, we consider the case in which \(x_1 \in \{a_1, b_1\}\) and \(x_2\in \{a_2, b_2\}\).

Finite upper bound. First suppose \(a_1\), \(b_1\), \(a_2\), and \(b_2\) are all finite. Take h to be the line through the points \((x_1, g_1(x_1))\) and \((x_2, g_2(x_2))\), i.e., the parameters are \(\alpha = (g(x_2) - g_1(x_1))/(x_2 - x_1)\) and \(\beta = \alpha x_1 - g_1(x_1)\). Note that if \(x_1 = x_2\), then h is ill-defined, and these candidate values of \(x_1\) and \(x_2\) can be skipped.

To verify that these values of \(\alpha \), \(\beta \), \(x_1\), and \(x_2\) parameterize a valid convex envelope of f, we check condition (23). Recall that the first condition only need hold if \(a_1 < b_1\), and the second if \(a_2 < b_2\). For example, if \(a_1=b_1<a_2=b_2\), then any combination of \(x_1 \in \{a_1, b_1\}\) and \(x_2 \in \{a_2, b_2\}\) are immediately valid.

Infinite upper bound. Now we consider the case when \(x_2 = b_2 = \infty \). In this case, we require \(h'(\infty ) = g_2'(\infty )\), i.e., \(p_2 = 0\) and \(\alpha = q_2\). We then have \(\beta = g_1(x_1) - q_2 x_1\). To verify that \(\alpha \), \(\beta \), \(x_1\), and \(x_2\) parameterize a valid envelope of f, we need only check the first condition of (23).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Moehle, N., Gindi, J., Boyd, S. et al. Portfolio construction as linearly constrained separable optimization. Optim Eng 24, 1667–1687 (2023). https://doi.org/10.1007/s11081-022-09748-x

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11081-022-09748-x

Keywords

Navigation