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
Star Strider 2019년 11월 6일
How are you calling portfolioReturn?
Hari Krishna Ravuri
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에 대해 자세히 알아보기

질문:

2019년 11월 5일

댓글:

2019년 11월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by