Help me with my function
显示 更早的评论
function [E_Rp, sigma_Rp] = portfolioReturn( weight, expRets, vols, corr)
% compute the expected return and volatility of a portfolio of two assets
%%input parameters
% weight - weight of Asset 1
% expRets - 2x1 vector of expected returns of the two assets
% vols - 2x1 vector of vector of volatilities of the two assets
% corr - correlation between the two assets
%%output parameters
% E_Rp - expected return of the portfolio
% sigma_Rp - volatility of the portfolio
E_Rp = [weight,(1-weight)] * expRets';
Variance_of_two = [weight^2,(1-weight)^2]* vols'+ 2* weight*(1-weight)*corr ;
sigma_Rp = sqrt(Variance_of_two);
end
I wrote this function to compute expected return and volatility of a portfolio
It should work as follows , but why it does not work in the fuctioin with same script
expRets = [0.136,0.150];
weight = 0.4;
E_Rp = [weight,(1-weight)] * expRets'
2 个评论
Star Strider
2019-11-6
How are you calling portfolioReturn?
Hari Krishna Ravuri
2019-11-8
The function looks fine. Provide some more information regarding the usage of the function.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!