| 所在主题: | |
| 文件名: matlab代码.zip | |
| 资料下载链接地址: https://bbs.pinggu.org/a-3386459.html | |
| 附件大小: | |
|
用matlab求解black-litterman模型
不加资产比例限制的时候表现正常 加入资产比例限制后输出资产比例变为[1,0,0,0,0,0,0,0,0,0] 代码如下:求教各位大神! function [er, ps, w, posteriorSigma] = BL_constrained(delta, weq, sigma, tau, P, Q, Omega,CashRet)%#codegen % hlblacklitterman % This function performs the Black-Litterman blending of the prior % and the views into a new posterior estimate of the returns as % described in the paper by He and Litterman. % Inputs % delta- Risk tolerance from the equilibrium portfolio % weq - Weights of the assets in the equilibrium portfolio % sigma- Prior covariance matrix % tau - Coefficiet of uncertainty in the prior estimate of the mean (pi) % P - Pick matrix for the view(s) % Q - Vector of view returns % Omega- Matrix of variance of the views (diagonal) % Outputs % Er - Posterior estimate of the mean returns % w - constrained weights computed given the Posterior estimates % of the mean and covariance of returns. % lambda - A measure of the impact of each view on the posterior estimates. % theta- A measure of the share of the prior and sample information in the % posterior precision. % Reverse optimize and back out the equilibrium returns % This is formula (12) page 6. pi = weq * sigma * delta; % We use tau * sigma many places so just compute it once ts = tau * sigma; % Compute posterior estimate of the mean % This is a simplified version of formula (8) on page 4. er = pi' + ts * P' * inv(P * ts * P' + Omega) * (Q - P * pi'); % We can also do it the long way to illustrate that d1 + d2 = I d = inv(inv(ts) + P' * inv(Omega) * P); d1 = d * inv(ts); d2 = d * P' * inv(Omega) * P; er2 = d1 * pi' + d2 * pinv(P) * Q; % Compute posterior estimate of the uncertainty in the mean % This is a simplified and combined version of formulas (9) and (15) ps = ts - ts * P' * inv(P * ts * P' + Omega) * P * ts; posteriorSigma = sigma + ps; %用Portfolio函数计算约束条件下的权重 p = Portfolio('RiskFreeRate', CashRet); p = p.setAssetMoments(er,posteriorSigma); p = p.setDefaultConstraints; w = estimateMaxSharpeRatio(p); |
|
熟悉论坛请点击新手指南
|
|
| 下载说明 | |
|
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。 2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。 3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。 (如有侵权,欢迎举报) |
|
京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明