This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

estimateFrontier

Estimate specified number of optimal portfolios on the efficient frontier

Syntax

[pwgt,pbuy,psell] = estimateFrontier(obj)
[pwgt,pbuy,psell] = estimateFrontier(obj,NumPorts)

Description

example

[pwgt,pbuy,psell] = estimateFrontier(obj) estimates the specified number of optimal portfolios on the efficient frontier for Portfolio, PortfolioCVaR, or PortfolioMAD objects. For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

example

[pwgt,pbuy,psell] = estimateFrontier(obj,NumPorts) estimates the specified number of optimal portfolios on the efficient frontier with an additional option specified for NumPorts.

Examples

collapse all

Create efficient portfolios:

load CAPMuniverse

p = Portfolio('AssetList',Assets(1:12));
p = estimateAssetMoments(p, Data(:,1:12),'missingdata',true);
p = setDefaultConstraints(p);
plotFrontier(p);

pwgt = estimateFrontier(p, 5);

pnames = cell(1,5);
for i = 1:5
	pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
            Port1        Port2       Port3       Port4      Port5
    AAPL     0.017926    0.058247    0.097816    0.12955    0    
    AMZN            0           0           0          0    0    
    CSCO            0           0           0          0    0    
    DELL    0.0041906           0           0          0    0    
    EBAY            0           0           0          0    0    
    GOOG      0.16144     0.35678     0.55228    0.75116    1    
    HPQ      0.052566    0.032302    0.011186          0    0    
    IBM       0.46422     0.36045     0.25577    0.11928    0    
    INTC            0           0           0          0    0    
    MSFT      0.29966     0.19222    0.082949          0    0    
    ORCL            0           0           0          0    0    
    YHOO            0           0           0          0    0    

Create a Portfolio object for 12 stocks based on CAPMuniverse.mat.

load CAPMuniverse
p0 = Portfolio('AssetList',Assets(1:12));
p0 = estimateAssetMoments(p0, Data(:,1:12),'missingdata',true);
p0 = setDefaultConstraints(p0);

Use setMinMaxNumAssets to define a maximum number of 3 assets.

p1 = setMinMaxNumAssets(p0, [], 3);

Use setBounds to define a lower and upper bound and a BoundType of 'Conditional'.

p1 = setBounds(p1, 0.1, 0.5,'BoundType', 'Conditional');
pwgt = estimateFrontier(p1, 5);     

The following table shows that the optimized allocations only have maximum 3 assets invested, and small positions less than 0.1 are avoided.

result = table(p0.AssetList', pwgt)
result=12×2 table
     Var1                            pwgt                        
    ______    ___________________________________________________

    'AAPL'          0          0          0    0.14301          0
    'AMZN'          0          0          0          0          0
    'CSCO'          0          0          0          0          0
    'DELL'          0          0          0          0          0
    'EBAY'          0          0          0          0        0.5
    'GOOG'    0.16981    0.29588    0.42214    0.49999        0.5
    'HPQ'           0          0          0          0          0
    'IBM'     0.49592    0.43629    0.37308    0.35699          0
    'INTC'          0          0          0          0          0
    'MSFT'    0.33426    0.26783    0.20478          0          0
    'ORCL'          0          0          0          0          0
    'YHOO'          0          0          0          0          0

The estimateFrontier function uses the MINLP solver to solve this problem. Use the setSolverMINLP function to configure the SolverType and options.

p1.solverTypeMINLP
ans = 
'OuterApproximation'
p1.solverOptionsMINLP
ans = struct with fields:
                           MaxIterations: 1000
                    AbsoluteGapTolerance: 1.0000e-07
                    RelativeGapTolerance: 1.0000e-05
                  NonlinearScalingFactor: 1000
                  ObjectiveScalingFactor: 1000
                                 Display: 'off'
                           CutGeneration: 'basic'
                MaxIterationsInactiveCut: 30
                      ActiveCutTolerance: 1.0000e-07
                  IntMasterSolverOptions: [1x1 optim.options.Intlinprog]
    NumIterationsEarlyIntegerConvergence: 30

Create efficient portfolios:

load CAPMuniverse

p = PortfolioCVaR('AssetList',Assets(1:12));
p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

plotFrontier(p);

pwgt = estimateFrontier(p, 5);

pnames = cell(1,5);
for i = 1:5
	pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
            Port1         Port2         Port3          Port4         Port5
    AAPL      0.010984      0.073247        0.11937       0.13068    0    
    AMZN    1.7632e-38             0              0    4.4451e-23    0    
    CSCO             0             0    -1.7632e-38    2.2226e-23    0    
    DELL      0.022454             0              0    8.8625e-22    0    
    EBAY             0             0              0    2.6671e-22    0    
    GOOG       0.20335       0.38055        0.56241       0.75932    1    
    HPQ       0.041725     0.0099217              0    5.0008e-23    0    
    IBM        0.44482       0.36453         0.2628          0.11    0    
    INTC    7.3468e-40     2.351e-38              0    1.7781e-22    0    
    MSFT       0.27667       0.17175       0.055424    4.4451e-23    0    
    ORCL             0    1.4106e-37              0    1.1113e-23    0    
    YHOO             0             0              0    4.8691e-22    0    

Create efficient portfolios:

load CAPMuniverse

p = PortfolioMAD('AssetList',Assets(1:12));
p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);
p = setDefaultConstraints(p);

plotFrontier(p);

pwgt = estimateFrontier(p, 5);

pnames = cell(1,5);
for i = 1:5
	pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
            Port1         Port2         Port3         Port4          Port5
    AAPL      0.030223      0.075387       0.11279        0.13456    0    
    AMZN             0    6.1948e-23    3.0775e-22     -8.583e-34    0    
    CSCO    6.0944e-22    9.3319e-23    3.3568e-22              0    0    
    DELL     0.0088968    1.0773e-21    1.8115e-22      2.616e-17    0    
    EBAY    1.4386e-21             0             0    -6.8686e-34    0    
    GOOG       0.16119       0.35202       0.54487        0.74888    1    
    HPQ       0.056534       0.02405    2.1051e-22              0    0    
    IBM        0.45909       0.37889       0.29384        0.11656    0    
    INTC             0             0    3.3783e-24    -5.8399e-35    0    
    MSFT       0.28406       0.16965      0.048509              0    0    
    ORCL    4.2498e-22    6.4439e-23             0     3.1796e-17    0    
    YHOO             0             0    3.3578e-21     2.1942e-18    0    

Obtain the default number of efficient portfolios over the entire range of the efficient frontier.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];

p = Portfolio;
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
pwgt = estimateFrontier(p);
disp(pwgt);
  Columns 1 through 7

    0.8891    0.7215    0.5540    0.3865    0.2190    0.0515         0
    0.0369    0.1289    0.2209    0.3129    0.4049    0.4969    0.4049
    0.0404    0.0567    0.0730    0.0893    0.1056    0.1219    0.1320
    0.0336    0.0929    0.1521    0.2113    0.2705    0.3297    0.4630

  Columns 8 through 10

         0         0         0
    0.2314    0.0579         0
    0.1394    0.1468         0
    0.6292    0.7953    1.0000

Starting from the initial portfolio, the estimateFrontier function returns purchases and sales to get from your initial portfolio to each efficient portfolio on the efficient frontier. Given an initial portfolio in pwgt0, you can obtain purchases and sales.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];
 
p = Portfolio;
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];
p = setInitPort(p, pwgt0);
[pwgt, pbuy, psell] = estimateFrontier(p);

display(pwgt);
pwgt = 4×10

    0.8891    0.7215    0.5540    0.3865    0.2190    0.0515         0         0         0         0
    0.0369    0.1289    0.2209    0.3129    0.4049    0.4969    0.4049    0.2314    0.0579         0
    0.0404    0.0567    0.0730    0.0893    0.1056    0.1219    0.1320    0.1394    0.1468         0
    0.0336    0.0929    0.1521    0.2113    0.2705    0.3297    0.4630    0.6292    0.7953    1.0000

display(pbuy);
pbuy = 4×10

    0.5891    0.4215    0.2540    0.0865         0         0         0         0         0         0
         0         0         0    0.0129    0.1049    0.1969    0.1049         0         0         0
         0         0         0         0         0         0         0         0         0         0
         0         0    0.0521    0.1113    0.1705    0.2297    0.3630    0.5292    0.6953    0.9000

display(psell);
psell = 4×10

         0         0         0         0    0.0810    0.2485    0.3000    0.3000    0.3000    0.3000
    0.2631    0.1711    0.0791         0         0         0         0    0.0686    0.2421    0.3000
    0.1596    0.1433    0.1270    0.1107    0.0944    0.0781    0.0680    0.0606    0.0532    0.2000
    0.0664    0.0071         0         0         0         0         0         0         0         0

Obtain the default number of efficient portfolios over the entire range of the efficient frontier.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

pwgt = estimateFrontier(p);

disp(pwgt);
  Columns 1 through 7

    0.8454    0.6847    0.5154    0.3541    0.1901    0.0314    0.0000
    0.0599    0.1427    0.2302    0.3165    0.3980    0.4733    0.3513
    0.0463    0.0639    0.0938    0.1079    0.1345    0.1583    0.1756
    0.0485    0.1087    0.1606    0.2215    0.2773    0.3371    0.4731

  Columns 8 through 10

    0.0000    0.0000         0
    0.1806         0         0
    0.1916    0.2212         0
    0.6278    0.7788    1.0000

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

Starting from the initial portfolio, the estimateFrontier function returns purchases and sales to get from your initial portfolio to each efficient portfolio on the efficient frontier. Given an initial portfolio in pwgt0, you can obtain purchases and sales.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 20000);
p = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];
p = setInitPort(p, pwgt0);
[pwgt, pbuy, psell] = estimateFrontier(p);

display(pwgt);
pwgt = 4×10

    0.8454    0.6847    0.5154    0.3541    0.1901    0.0314    0.0000    0.0000    0.0000         0
    0.0599    0.1427    0.2302    0.3165    0.3980    0.4733    0.3513    0.1806         0         0
    0.0463    0.0639    0.0938    0.1079    0.1345    0.1583    0.1756    0.1916    0.2212         0
    0.0485    0.1087    0.1606    0.2215    0.2773    0.3371    0.4731    0.6278    0.7788    1.0000

display(pbuy);
pbuy = 4×10

    0.5454    0.3847    0.2154    0.0541         0         0         0         0         0         0
         0         0         0    0.0165    0.0980    0.1733    0.0513         0         0         0
         0         0         0         0         0         0         0         0    0.0212         0
         0    0.0087    0.0606    0.1215    0.1773    0.2371    0.3731    0.5278    0.6788    0.9000

display(psell);
psell = 4×10

         0         0         0         0    0.1099    0.2686    0.3000    0.3000    0.3000    0.3000
    0.2401    0.1573    0.0698         0         0         0         0    0.1194    0.3000    0.3000
    0.1537    0.1361    0.1062    0.0921    0.0655    0.0417    0.0244    0.0084         0    0.2000
    0.0515         0         0         0         0         0         0         0         0         0

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

Obtain the default number of efficient portfolios over the entire range of the efficient frontier.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);

pwgt = estimateFrontier(p);

disp(pwgt);
  Columns 1 through 7

    0.8816    0.7151    0.5488    0.3817    0.2170    0.0499    0.0000
    0.0430    0.1282    0.2128    0.2981    0.3824    0.4662    0.3609
    0.0389    0.0604    0.0826    0.1053    0.1241    0.1492    0.1786
    0.0365    0.0963    0.1559    0.2149    0.2764    0.3348    0.4605

  Columns 8 through 10

    0.0000    0.0000         0
    0.1755         0         0
    0.2095    0.2266         0
    0.6150    0.7734    1.0000

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

Starting from the initial portfolio, the estimateFrontier function returns purchases and sales to get from your initial portfolio to each efficient portfolio on the efficient frontier. Given an initial portfolio in pwgt0, you can obtain purchases and sales.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 20000);
p = PortfolioMAD;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);

pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];
p = setInitPort(p, pwgt0);
[pwgt, pbuy, psell] = estimateFrontier(p);

display(pwgt);
pwgt = 4×10

    0.8816    0.7151    0.5488    0.3817    0.2170    0.0499    0.0000    0.0000    0.0000         0
    0.0430    0.1282    0.2128    0.2981    0.3824    0.4662    0.3609    0.1755         0         0
    0.0389    0.0604    0.0826    0.1053    0.1241    0.1492    0.1786    0.2095    0.2266         0
    0.0365    0.0963    0.1559    0.2149    0.2764    0.3348    0.4605    0.6150    0.7734    1.0000

display(pbuy);
pbuy = 4×10

    0.5816    0.4151    0.2488    0.0817         0         0         0         0         0         0
         0         0         0         0    0.0824    0.1662    0.0609         0         0         0
         0         0         0         0         0         0         0    0.0095    0.0266         0
         0         0    0.0559    0.1149    0.1764    0.2348    0.3605    0.5150    0.6734    0.9000

display(psell);
psell = 4×10

         0         0         0         0    0.0830    0.2501    0.3000    0.3000    0.3000    0.3000
    0.2570    0.1718    0.0872    0.0019         0         0         0    0.1245    0.3000    0.3000
    0.1611    0.1396    0.1174    0.0947    0.0759    0.0508    0.0214         0         0    0.2000
    0.0635    0.0037         0         0         0         0         0         0         0         0

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

Input Arguments

collapse all

Object for portfolio, specified using Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

Data Types: object

Number of points to obtain on the efficient frontier, specified as a scalar integer.

Note

If no value is specified for NumPorts, the default value is obtained from the hidden property defaultNumPorts (default value is 10). If NumPorts = 1, this function returns the portfolio specified by the hidden property defaultFrontierLimit (current default value is 'min').

Data Types: double

Output Arguments

collapse all

Optimal portfolios on the efficient frontier with specified number of portfolios spaced equally from minimum to maximum portfolio return, returned as a NumAssets-by-NumPorts matrix. pwgt is returned for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Purchases relative to an initial portfolio for optimal portfolios on the efficient frontier, returned as NumAssets-by-NumPorts matrix.

Note

If no initial portfolio is specified in obj.InitPort, that value is assumed to be 0 such that pbuy = max(0, pwgt) and psell = max(0, -pwgt).

pbuy is returned for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Sales relative to an initial portfolio for optimal portfolios on the efficient frontier, returned as a NumAssets-by-NumPorts matrix.

Note

If no initial portfolio is specified in obj.InitPort, that value is assumed to be 0 such that pbuy = max(0, pwgt) and psell = max(0, -pwgt).

psell is returned for Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Tips

  • You can also use dot notation to estimate the specified number of optimal portfolios over the entire efficient frontier.

     	[pwgt, pbuy, psell] = obj.estimateFrontier(NumPorts);

  • When introducing transaction costs and turnover constraints to the Portfolio, PortfolioCVaR, or PortfolioMAD object, the portfolio optimization objective contains a term with an absolute value. For more information on how Financial Toolbox™ handles such cases algorithmically, see References.

References

[1] Cornuejols, G., and R. Tutuncu. Optimization Methods in Finance. Cambridge University Press, 2007.

Introduced in R2011a