AlgoQuant, an integrated trading strategy research and backtesting system
com.numericalmethod.algoquant.model.portfoliooptimization.markowitz

## Class MarkowitzUtils

• java.lang.Object
• com.numericalmethod.algoquant.model.portfoliooptimization.markowitz.MarkowitzUtils

• public class MarkowitzUtils
extends Object
This is a collection of utilities to compute Markowitz optimal portfolio weightings in different settings.
• ### Method Summary

All Methods
Modifier and Type Method and Description
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturns(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn)
Given a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1$ Short selling is possible.
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturnsNoShortSelling(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn)
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1, w \geq 0$ There is no short selling.
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturnsWithMinimumWeights(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn, com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1, w \geq w_{min}$
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturn(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn)
Given a target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1$ Short selling is possible.
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturnNoShortSelling(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn, com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1, w \geq w_{min}$ And, there is no short selling.
static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturnWithMinimumWeights(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu, com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma, double targetReturn, com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1, w \geq w_{min}$
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Method Detail

• #### getWeightsForTargetReturn

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturn(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn)
Given a target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1$ Short selling is possible.
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
Returns:
the Markowitz portfolio weights
"Tze Leung Lai, Haipeng Xing, Zehao Chen. "Eq. 1.2, Mean-variance portfolio optimization when means and covariances are unknown," Annals of Applied Statistics 2011, Vol. 5, No. 2A, 798-823"
• #### getWeightsForTargetReturnWithMinimumWeights

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturnWithMinimumWeights(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn,
com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
throws com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible,
Exception
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1, w \geq w_{min}$
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
minWeights - the minimum weights, e.g., 0 for no short selling
Returns:
the Markowitz portfolio weights
Throws:
com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible - when the optimization failed
Exception
"Tze Leung Lai, Haipeng Xing, Zehao Chen. "Eq. 1.2, Mean-variance portfolio optimization when means and covariances are unknown," Annals of Applied Statistics 2011, Vol. 5, No. 2A, 798-823"
• #### getWeightsForTargetReturnNoShortSelling

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForTargetReturnNoShortSelling(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn,
com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
throws com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible,
Exception
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu = \mu*, w'1 = 1, w \geq w_{min}$ And, there is no short selling.
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
minWeights - the minimum weights, e.g., 0 for no short selling
Returns:
the Markowitz portfolio weights
Throws:
com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible - when the optimization failed
Exception
"Tze Leung Lai, Haipeng Xing, Zehao Chen. "Eq. 1.2, Mean-variance portfolio optimization when means and covariances are unknown," Annals of Applied Statistics 2011, Vol. 5, No. 2A, 798-823"
• #### getWeightsForMinReturns

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturns(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn)
throws com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible,
Exception
Given a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1$ Short selling is possible.
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
Returns:
the Markowitz portfolio weights
Throws:
com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible - when the optimization failed
Exception
"Tze Leung Lai, Haipeng Xing, Zehao Chen. "Eq. 1.2, Mean-variance portfolio optimization when means and covariances are unknown," Annals of Applied Statistics 2011, Vol. 5, No. 2A, 798-823"
• #### getWeightsForMinReturnsWithMinimumWeights

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturnsWithMinimumWeights(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn,
com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector minWeights)
throws com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible,
Exception
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1, w \geq w_{min}$
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
minWeights - the minimum weights, e.g., 0 for no short selling
Returns:
the Markowitz portfolio weights
Throws:
com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible - when the optimization failed
Exception
"Tze Leung Lai, Haipeng Xing, Zehao Chen. "Eq. 1.2, Mean-variance portfolio optimization when means and covariances are unknown," Annals of Applied Statistics 2011, Vol. 5, No. 2A, 798-823"
• #### getWeightsForMinReturnsNoShortSelling

public static com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector getWeightsForMinReturnsNoShortSelling(com.numericalmethod.suanshu.algebra.linear.vector.doubles.Vector mu,
com.numericalmethod.suanshu.algebra.linear.matrix.doubles.Matrix sigma,
double targetReturn)
throws com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible,
Exception
Given the minimum allocation weights, and a minimum guaranteed target value μ* for the mean return of a portfolio, Markowitz characterizes an efficient portfolio by its weight vector w_eff that solves the optimization problem: $w_{eff} = \arg\min \left \{ w'\Sigma w \right \} \\ \text{s.t.,} w'\mu \geq \mu*, w'1 = 1, w \geq 0$ There is no short selling.
Parameters:
mu - expected future returns
sigma - expected future covariances
targetReturn - target return, μ
Returns:
the Markowitz portfolio weights
Throws:
com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible - when the optimization failed
Exception