Class PortfolioOptimizer
java.lang.Object
com.quantfinlib.optimization.PortfolioOptimizer
Long-only, fully invested mean-variance optimisation (Markowitz 1952),
solved exactly as convex quadratic programs by
QuadraticProgram:
- minimum variance:
min w'Σws.t.1'w = 1, w ≥ 0; - frontier point: the same with
μ'w = targetadded; - maximum Sharpe: by the homogenisation of the linear-fractional
problem (Cornuéjols and Tütüncü, Optimization Methods in Finance,
2007, §8.2):
min y'Σys.t.(μ − r_f)'y = 1, y ≥ 0, thenw = y / 1'y. It needs at least one asset withμ_i > r_f; otherwise no long-only portfolio has a positive excess return and the method throws.
Results are optimal to rounding (the active-set method terminates on the KKT conditions). Expected returns and covariance must share the same periodicity. The covariance is copied and must be symmetric and positive semi-definite.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn optimized allocation with its risk/return profile (same periodicity as the inputs). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionefficientFrontier(int points) Minimum-variance frontier: for each ofpointstarget returns evenly spaced from the lowest to the highest asset expected return, the long-only portfolio of least variance that earns exactly that return.maxSharpe(double riskFreeRate) Maximum Sharpe ratio portfolio.Minimum volatility portfolio.static double[]rebalance(double[] currentWeights, double[] targetWeights) Rebalancing deltas: target minus current weights, per asset.
-
Constructor Details
-
PortfolioOptimizer
public PortfolioOptimizer(double[] expectedReturns, double[][] covariance)
-
-
Method Details
-
maxSharpe
Maximum Sharpe ratio portfolio.riskFreeRatein the same periodicity as the inputs. -
minVolatility
Minimum volatility portfolio. -
efficientFrontier
Minimum-variance frontier: for each ofpointstarget returns evenly spaced from the lowest to the highest asset expected return, the long-only portfolio of least variance that earns exactly that return. Points below the minimum-variance portfolio's return are on the inefficient lower branch; filter by return if only the efficient part is wanted. -
rebalance
public static double[] rebalance(double[] currentWeights, double[] targetWeights) Rebalancing deltas: target minus current weights, per asset.
-