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 Kommentare

Star Strider
Star Strider am 6 Nov. 2019
How are you calling portfolioReturn?
Hari Krishna Ravuri
Hari Krishna Ravuri am 8 Nov. 2019
The function looks fine. Provide some more information regarding the usage of the function.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Portfolio Optimization and Asset Allocation finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 5 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by