[Returnanalytics-commits] r3245 - pkg/PortfolioAnalytics/sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 5 22:58:22 CET 2013


Author: braverock
Date: 2013-11-05 22:58:22 +0100 (Tue, 05 Nov 2013)
New Revision: 3245

Added:
   pkg/PortfolioAnalytics/sandbox/GMV_analytical.R
   pkg/PortfolioAnalytics/sandbox/MSR_analytical.R
Log:
- analytical solutions to global minimum variance and maximum Sharpe ratio portfolios, contributed by Kyle Balkisoon kyle <at> corporateknights <dot> com


Added: pkg/PortfolioAnalytics/sandbox/GMV_analytical.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/GMV_analytical.R	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/GMV_analytical.R	2013-11-05 21:58:22 UTC (rev 3245)
@@ -0,0 +1,22 @@
+GMV = function (sigma) {
+ 
+  #'Global Minimum Variance
+  #'Calculates the portfolio weights in accordance with a minimum variance strategy.
+  #'From Goltz, F. & Lodh, A. 2013 "Scientific Beta Efficient Minimum Volatility Indices " EDHEC-Risk Institute Scientific Beta(2013)
+  #'@Title Global Minimum Variance 
+    #'@author Corporate Knights Inc.: Michael Fong /email{mfong at corporateknights.com}, Kyle Balkissoon /email{kyle at corporateknights.com}
+    #'@param sigma = Covariance matrix of returns
+    #'
+    #'  
+    step1 = sigma
+    unit_vector = c(rep(1,ncol(step1)))
+    # Calculate GMV portfolio weight matrix    
+    step2 = (step1)^(-1)%*%unit_vector
+    step3 = as.numeric(t(unit_vector)%*%(step1)^(-1)%*%unit_vector)
+    step4 = step2/step3
+    # Long-Only Adjustment - Set negative weights to zero  
+    step5 = ifelse(step4<0,0,step4) 
+    # Normalize Weights  
+    step6 = step5/sum(step5)
+    return(step6)
+}
\ No newline at end of file

Added: pkg/PortfolioAnalytics/sandbox/MSR_analytical.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/MSR_analytical.R	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/MSR_analytical.R	2013-11-05 21:58:22 UTC (rev 3245)
@@ -0,0 +1,24 @@
+MSR = function (sigma,return_estimate,long_only) {
+  
+  #'Maximum Sharpe Ratio
+  #'Calculates the portfolio weights in accordance with a maximum sharpe ratio strategy.
+  #'From Gautam, K. & Lodh, A. 2013 "Scientific Beta Efficient Maximum Sharpe Ratio Indices " EDHEC-Risk Institute Scientific Beta(2013)
+  #'@Title Efficient Maximum Sharpe Ratio
+    #'@author Corporate Knights Inc.: Michael Fong /email{mfong at corporateknights.com}, Kyle Balkissoon /email{kyle at corporateknights.com}
+    #'@param sigma = Covariance matrix of returns
+    #'@param return_estimate = vector of expected returns (or) expected returns - risk free rate 
+    #'
+    #' 
+  step1 = sigma
+  unit_vector = c(rep(1,ncol(step1)))
+  #Calculate EMS portfolio weight matrix   
+  step2 = (step1)^(-1)%*%return_estimate 
+  step3 = as.numeric((unit_vector)%*%(step1)^(-1)%*%return_estimate)
+  step4 = step2/step3
+  # Long-Only Adjustment - Set negative weights to zero    
+  if(long_only=='TRUE'){step5 = ifelse(step4<0,0,step4)
+}else{step5 = step4}
+  # Normalize Weights  
+  step6 = step5/sum(step5)
+  return(t(step6))
+}
\ No newline at end of file



More information about the Returnanalytics-commits mailing list