matlab frontier,Plot efficient frontier

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.

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

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

pWithConditionalBound = setBounds(p0, 0.1, 0.5,'BoundType', 'Conditional');

Use plotFrontier to compare the different portfolio objects.

figure;

plotFrontier(p0); hold on;

plotFrontier(pWithMaxNumAssets); hold on;

plotFrontier(pWithConditionalBound); hold off;

legend('p0', 'with Max 3 assets invested', ' with each asset weight 0 or [0.1, 0.5]', 'location', 'best');

af392404105775d883758d18a6f5c273.png

Define a target return and use estimateFrontierByReturn to compare the three portfolio objects.

targetRetn = 2.0e-3;

pwgt0 = estimateFrontierByReturn(p0, targetRetn);

pwgtWithMaxNumAssets = estimateFrontierByReturn(pWithMaxNumAssets, targetRetn);

pwgtConditionalBound = estimateFrontierByReturn(pWithConditionalBound, targetRetn);

The following table shows the final allocation for specified target return among the three portfolio objects. You can see that the small positions in 'AAPL'and 'HPQ' are avoided in pwgtConditionalBound, and only three assets are invested in pwgtWithMaxNumAssets.

result = table(p0.AssetList',pwgt0,pwgtWithMaxNumAssets,pwgtConditionalBound)

result=12×4 table

Var1 pwgt0 pwgtWithMaxNumAssets pwgtConditionalBound

________ ________ ____________________ ____________________

{'AAPL'} 0.076791 0 0.1

{'AMZN'} 0 0 0

{'CSCO'} 0 0 0

{'DELL'} 0 0 0

{'EBAY'} 0 0 0

{'GOOG'} 0.44841 0.47297 0.44255

{'HPQ' } 0.022406 0 0

{'IBM' } 0.31139 0.34762 0.31592

{'INTC'} 0 0 0

{'MSFT'} 0.14101 0.17941 0.14153

{'ORCL'} 0 0 0

{'YHOO'} 0 0 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值