Help me with my function
Mostrar comentarios más antiguos
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 comentarios
Star Strider
el 6 de Nov. de 2019
How are you calling portfolioReturn?
Hari Krishna Ravuri
el 8 de Nov. de 2019
The function looks fine. Provide some more information regarding the usage of the function.
Respuestas (0)
Categorías
Más información sobre Portfolio Optimization and Asset Allocation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!