Code for finding optimal portfolios and plotting efficient frontier for diff. risk return measures
Sharpe( weights )
function [ opmvsharp ] = Sharpe( weights )
%This function calculates the Sharpe ratio or Risk return ratio of a
%portfolio. The function is then used with "fmincon", MATLAB's optimization
%command to find the portfolio that has maximum Sharpe ratio.
%declaring variables to be used with the function
global meanvar VCV meanret;
%calculating portfolio returns
mvportret=meanret*weights;
%Calculating portfolio risk
mvrisk=sqrt(weights'*VCV*weights);
%Calculating Sharpe's Ratio
opmvsharp=-mvportret/mvrisk;
end