Case Study _均值方差模型 MatLab

%%设置初始表格
Asset = { ‘Bonds’, ‘Large-Cap Equities’, ‘Small-Cap Equities’, ‘Emerging Equities’ };
Price = [ 52.4; 122.7; 35.2; 46.9 ];
Holding = [ 42938; 24449; 42612; 15991 ];
UnitCost = [ 0.001; 0.001; 0.001; 0.004 ];

Blotter = table(‘RowNames’, Asset);
Blotter.Price = Price;
Blotter.InitHolding = Holding;
Wealth = sum(Blotter.Price .* Blotter.InitHolding);
Blotter.InitPort = (1/Wealth)(Blotter.Price . Blotter.InitHolding);
Blotter.UnitCost = UnitCost;
Blotter
%% 模拟价格
AssetMean = [ 0.05; 0.1; 0.12; 0.18 ];
AssetCovar = [ 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 ];

X = portsim(AssetMean’/12, AssetCovar/12, 60); % monthly total returns for 5 years (60 months)
[Y, T] = ret2tick(X, [], 1/12); % form total return prices

%%不包含手续费---------------------------------------------------
pp = Portfolio(‘Name’, ‘Asset Allocation Portfolio’, …
‘AssetList’, Asset, ‘InitPort’, Blotter.InitPort);
%%设置交易条件
p = setDefaultConstraints§;
p = setGroups(p, [ 0, 1, 1, 1 ], [], 0.85);
p = addGroups(p, [ 0, 0, 0, 1 ], [], 0.35);

p = setAssetMoments(p, AssetMean/12, AssetCovar/12);
p = estimateAssetMoments(p, Y, ‘DataFormat’, ‘Prices’);%%获得均值和方差

p.AssetMean = 12p.AssetMean;
p.AssetCovar = 12
p.AssetCovar;

display§;
%% 看组合是否能够优化
[lb,ub] = estimateBounds§’
disp([lb,ub]);
%%画出有效前沿
plotFrontier(p,40);

%%包含手续费-----------------------------------------------------
q = setCost(p,unitcost,unicost);
%%计算初始资产的风险和收益
[risk,ret] = estimatePortMoments(p,p.initPort);
%%计算有效前沿上最优组合
pret = estimatePortReturn(p, p.estimateFrontierLimits);
qret = estimatePortReturn(q, q.estimateFrontierLimits);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值