Second-order cone programming (SOCP) offers a robust and efficient way of solving several types of convex problems, including convex quadratically constrained quadratic programming (QCQP) problems. That is the reason why it can be highly utilized in a broad range of fields, like finance. At Mark 29.3 of the NAG Library, NAG introduces a performance update to the SOCP solver (nag_opt_handle_solve_socp_ipm) which has been shown to be particularly effective for portfolio optimization.

Second-order cone programming is one of the main methods for solving QCQP problems, which arises in applications such as portfolio construction. The standard form convex QCQP problem is:

where \(Q_{o},…, Q_{m} \) are positive semidefinite \(n\) x \(n\) matrices.

Figure 1: Feasible region of an SOCP problem with three variables.

The feasible region of an SOCP problem (which may, for instance, be a transformed QCQP problem) can be seen in Figure 1. The feasible region here is the intersection of the green polyhedron and a cone. The curve represents the added quadratic information which makes SOCP more complicated, but at the same time more powerful than LP.

In terms of the implementation of NAG’s SOCP solver, a path-following homogeneous self-dual algorithm is used. This is both robust and efficient and can detect infeasibility and unboundedness of the model. Also, NAG exploits the sparsity pattern of the problem thoroughly which makes the solver efficient, especially on large and sparse problems. For more details on implementation, see the NAG Library routine documentation for NAG SOCP solver nag_opt_handle_solve_socp_ipm [1].

It is rare that a second-order cone (SOC) would appear naturally in the model, yet through a model reformulation, many portfolio optimization problems and constraints can be handled by SOCP. We discuss several of these below, for more examples see [2].

The leverage constraint:

The above norm constraint can be viewed as a special case of general p-norm constraint on a vector $x\in {\mathbb{R}}^{n}$ defined as $$

$$

(1)

Where \(p = l / m \) is a positive rational number with \( l ≥ m \). Inequality constraints (1) have SOC representation since they are equivalent to inequalities involving rational powers.

The tracking error constraint

(2)

where \(P\)

since \( (1 / 2)x^TPx ≤ t \) is equivalent to \( || Fx||^2_{2} ≤ 2t\). Thus, adding auxiliary variables \( y = Fx \) will transform the quadratic constraint into a standard cone constraint.${\mathrm{}}_{}^{}$

For more details, see our mini article on QCQP and the python examples on portfolio optimization involving quadratic functions.

We have mentioned important SOC-representable functions above yet many more problems and constraints from portfolio optimization are SOC-representable. We list some below.

- Maximize Sharpe ratio:

- Holding and budget constraints:

where \(e\) is the vector of all ones.

- Maximum position constraint:

- Market impact cost:

We encourage users to exploit their models thoroughly to reach a SOC-equivalent problem, thereby making the most of the versatility and practical performance of the NAG SOCP solver nag_opt_handle_solve_socp_ipm.

In this section, we show the performance of the NAG SOCP solver from the NAG Library for Python together with the NAG SOCP solver called from CVXPY and the default solver in CVXPY. While we used Python, the same NAG SOCP solver is available in many other environments (C, Java, Fortran, etc.). All solvers were at default settings with accuracy at $1{0}^{-8}$ and in single-threaded mode.

The solvers were used on $10$ classic portfolio optimization problems ranging from 1100 to 2900 assets. Randomly generated data was used in a Markowitz model whose objective involved a large covariance matrix and was subject to a long-only constraint and a budget constraint.

The computational time comparison can be found in Figure 2. Here it can be seen that the NAG solver called from CVXPY is faster than the standard CVXPY solver. Further, for smaller problems, the NAG solver called from Python is at least twice as fast as standard CVXPY, becoming as much as five times faster for larger problems.

Figure 2: Comparison of time on $10$ portfolio optimization problems.

In conclusion, SOCP is widely used in finance due to its powerful nature. At Mark 29.3, NAG introduces an updated SOCP solver (nag_opt_handle_solve_socp_ipm) that is highly performant on portfolio optimization problems. In some cases, reformulation of your problem is required, yet it is worth the effort. For further examples and reading visit our GitHub Local optimization page.

The solver is available for multiple languages and environments including C and C++, Python, Java, .NET and Fortran, on Windows, Linux and MacOS. See the Getting Started page for how to download and install.

This will close in 20 seconds

This will close in 20 seconds