Path: blob/master/sandbox/MSR_analytical.R
1433 views
MSR = function (sigma,return_estimate,long_only) {12#'Maximum Sharpe Ratio3#'Calculates the portfolio weights in accordance with a maximum sharpe ratio strategy.4#'From Gautam, K. & Lodh, A. 2013 "Scientific Beta Efficient Maximum Sharpe Ratio Indices " EDHEC-Risk Institute Scientific Beta(2013)5#'@Title Efficient Maximum Sharpe Ratio6#'@author Corporate Knights Inc.: Michael Fong /email{[email protected]}, Kyle Balkissoon /email{[email protected]}7#'@param sigma = Covariance matrix of returns8#'@param return_estimate = vector of expected returns (or) expected returns - risk free rate9#'10#'11step1 = sigma12unit_vector = c(rep(1,ncol(step1)))13#Calculate EMS portfolio weight matrix14step2 = (step1)^(-1)%*%return_estimate15step3 = as.numeric((unit_vector)%*%(step1)^(-1)%*%return_estimate)16step4 = step2/step317# Long-Only Adjustment - Set negative weights to zero18if(long_only=='TRUE'){step5 = ifelse(step4<0,0,step4)19}else{step5 = step4}20# Normalize Weights21step6 = step5/sum(step5)22return(t(step6))23}2425