Mixed-Integer MAD Portfolio Optimization Problem
This example shows how to solve a MAD portfolio optimization problem with constraints in the number of selected assets or conditional (semicontinuous) bounds. To solve this problem, you can use a PortfolioMAD
object along with different mixed integer nonlinear programming (MINLP) solvers.
MAD Portfolio
Load the returns data in CAPMuniverse.mat
. Then, create a PortfolioMAD
object with default constraints and a long-only portfolio whose weights sum to 1
. For this example, you can define the feasible region of weights as
% Load data load CAPMuniverse.mat % Create MAD portfolio with default constraints p = PortfolioMAD; p = simulateNormalScenariosByData(p,Data(:,1:12),1000,missingdata=true); p = setDefaultConstraints(p);
Include binary variables for this scenario by setting conditional (semicontinuous) bounds. Conditional bounds are those such that or . In this example, for all assets.
% Set conditional bounds condLB = 0.1; condUB = 0.5; p = setBounds(p,condLB,condUB,BoundType="conditional");
Use estimateFrontier
to estimate a set of portfolios on the efficient frontier. The efficient frontier is a curve that shows the trade-off between the return and risk achieved by Pareto-optimal portfolios. For a given return level, the portfolio on the efficient frontier is the one that minimizes the risk while maintaining the desired return. Conversely, for a given risk level, the portfolio on the efficient frontier is the one that maximizes return while maintaining the desired risk level.
% Compute efficient frontier p = setSolverMINLP(p,'TrustRegionCP',DeltaLowerBound=condLB); pwgt = estimateFrontier(p)
pwgt = 12×10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0.1000 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0.1000 0.1279 0.1973 0.2316 0.2735 0.4375 0.5000
0.1709 0.2574 0.3502 0.3371 0.3996 0.4272 0.4812 0.4989 0.4625 0.5000
0 0.1000 0.1000 0.1000 0.1000 0 0 0 0 0
0.5000 0.3436 0.2375 0.1933 0.1000 0.1000 0 0.1276 0 0
0 0 0 0 0 0 0 0 0 0
0.3291 0.2990 0.3123 0.2696 0.2725 0.2755 0.2872 0 0.1000 0
⋮
% Compute risk and returns of the portfolios on the efficient frontier
rsk = estimatePortRisk(p,pwgt);
ret = estimatePortReturn(p,pwgt);
Plot the weights from the frontier estimation with plotFrontier
. The resulting curve is piece-wise concave with possible vertical jumps (discontinuities) between the concave intervals.
% Plot efficient frontier
plotFrontier(p,pwgt)
Changing MINLP Solvers
In the previous section, you use the default solver for estimateFrontier
. However, you can solve mixed-integer portfolio problems using any of these three three algorithms supported by setSolverMINLP
: OuterApproximation
, ExtendedCP
, and TrustRegionCP
. Furthermore, the OuterApproximation
algorithm accepts an additional name-value argument (ExtendedFormulation
) for Portfolio
problems, which reformulates problems with quadratic functions to work in an extended space that usually decreases the computation time. All algorithms, including the extended formulation variation of the OuterApproximation
algorithm, return the same values within numerical accuracy. The available solvers are:
OuterApproximation
— The default algorithm, which is robust and usually faster thanExtenedCP
OuterApproximation
withExtendedFormulation
set totrue
— A robust algorithm that is usually faster than other algorithms, but supported only forPortfolio
object problemsExtendedCP
— The most robust solver, but usually the slowestTrustRegionCP
— The fastest algorithm, but one that is less robust and may provide suboptimal solutions
For more information on solvers for mixed-integer portfolio problems, see Choose MINLP Solvers for Portfolio Problems.
To change the MINLP solvers, use setSolverMINLP
.
% Select 'TrustRegionCP' as solver p_OA = setSolverMINLP(p,'OuterApproximation'); pwgt_OA = estimateFrontier(p_OA); rskOA = estimatePortRisk(p,pwgt_OA); retOA = estimatePortReturn(p,pwgt_OA); % Select 'ExtendedCP' as solver using 'midway' cuts as 'CutGeneration' p_ECP = setSolverMINLP(p,'ExtendedCP',CutGeneration="midway"); pwgt_ECP = estimateFrontier(p_ECP); rskECP = estimatePortRisk(p,pwgt_ECP); retECP = estimatePortReturn(p,pwgt_ECP);
Compare the returns and risks obtained by the portfolios on the efficient frontier from the different solvers. They are all the same within a numerical accuracy where the absolute difference .
retTable = table(retOA,ret,retECP,'VariableNames',{'OA','TR','ECP'})
retTable=10×3 table
OA TR ECP
__________ __________ _________
0.00097434 0.00097297 0.0009746
0.0012019 0.0012006 0.0012021
0.0014294 0.0014283 0.0014296
0.0016569 0.001656 0.0016571
0.0018844 0.0018837 0.0018846
0.0021119 0.0021113 0.0021121
0.0023395 0.002339 0.0023395
0.002567 0.0025667 0.002567
0.0027945 0.0027944 0.0027945
0.003022 0.003022 0.003022
rskTable = table(rskOA,rsk,rskECP,'VariableNames',{'OA','TR','ECP'})
rskTable=10×3 table
OA TR ECP
________ ________ ________
0.015368 0.015368 0.015368
0.01556 0.015558 0.01556
0.016123 0.01612 0.016124
0.016849 0.016846 0.01685
0.017864 0.01786 0.017864
0.019127 0.019123 0.019127
0.020516 0.020513 0.020517
0.022074 0.02233 0.022074
0.023968 0.023965 0.023968
0.025807 0.025807 0.025807
% Compare risks from the different OuterApproximation formulations
norm(rskTable.OA-rskTable.TR,Inf) <= 1e-4
ans = logical
0
See Also
PortfolioMAD
| estimateFrontier
| estimateFrontierLimits
| estimateFrontierByReturn
| estimatePortReturn
| estimateFrontierByRisk
| estimatePortRisk
| estimateFrontierByRisk
Related Examples
- Estimate Efficient Portfolios Along the Entire Frontier for PortfolioMAD Object
- Creating the PortfolioMAD Object
- Working with MAD Portfolio Constraints Using Defaults
- Estimate Efficient Frontiers for PortfolioMAD Object
- Asset Returns and Scenarios Using PortfolioMAD Object