[Returnanalytics-commits] r3006 - in pkg/PerformanceAnalytics/sandbox/pulkit: R week1/code

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 6 02:00:33 CEST 2013


Author: pulkit
Date: 2013-09-06 02:00:33 +0200 (Fri, 06 Sep 2013)
New Revision: 3006

Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R
   pkg/PerformanceAnalytics/sandbox/pulkit/R/PSRopt.R
   pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R
   pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSROpt.py
Log:
change in initial weights PSR optimization

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R	2013-09-05 21:31:44 UTC (rev 3005)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R	2013-09-06 00:00:33 UTC (rev 3006)
@@ -107,12 +107,12 @@
         refSR = refSR[-index]
         sk = sk[-index]
         kr = kr[-index]
+        columnnames = columnnames[-index]
         warning(paste("The Reference Sharpe Ratio greater than the Observed Sharpe Ratio for case",columnnames[index],"\n"))    
     }
     result = 1 + (1 - sk*sr + ((kr-1)/4)*sr^2)*(qnorm(p)/(sr-refSR))^2
-    columnnames = columnnames[-index]
     if(!is.null(dim(result))){ 
-      colnames(result) = paste(columnnames,"(SR >",refSR,")") 
+      colnames(result) = paste(columnnames,"(SR >",round(refSR,2),")") 
       rownames(result) = paste("Probabilistic Sharpe Ratio(p=",round(p*100,1),"%):")
     }
     return(result)

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/PSRopt.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/PSRopt.R	2013-09-05 21:31:44 UTC (rev 3005)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/PSRopt.R	2013-09-06 00:00:33 UTC (rev 3006)
@@ -60,7 +60,7 @@
     }
     z = 0
     iter = 0
-    w = rep(1,columns)
+    w = rep(1,columns)/columns
     d1z = 0
     #Optimization Function
     optimize<-function(){

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R	2013-09-05 21:31:44 UTC (rev 3005)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R	2013-09-06 00:00:33 UTC (rev 3006)
@@ -106,13 +106,14 @@
         refSR = refSR[-index]
         sk = sk[-index]
         kr = kr[-index]
+        columnnames = columnnames[-index]
         warning(paste("The Reference Sharpe Ratio greater than the Observed Sharpe Ratio for case",columnnames[index],"\n"))
         
     }
-    result = pnorm(((sr - refSR)*(n-1)^(0.5))/(1-sr*sk+sr^2*(kr-1)/4)^(0.5))
-    columnnames = columnnames[-index]
+    result = pnorm(((sr - refSR)*((n-1)^(0.5)))/(1-sr*sk+(sr^2)*(kr-1)/4)^(0.5))
+
     if(!is.null(dim(result))){ 
-        colnames(result) = paste(columnnames,"(SR >",refSR,")") 
+        colnames(result) = paste(columnnames,"(SR >",round(refSR,2),")") 
         
         rownames(result) = paste("Probabilistic Sharpe Ratio(p=",round(p*100,1),"%):")
     }

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSROpt.py
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSROpt.py	2013-09-05 21:31:44 UTC (rev 3005)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSROpt.py	2013-09-06 00:00:33 UTC (rev 3006)
@@ -134,12 +134,12 @@
 def main():
     #1) Inputs (path to csv file with returns series)
     path='data.csv'
-    maxIter=1000 # Maximum number of iterations
+    maxIter=10000 # Maximum number of iterations
     delta=.005 # Delta Z (attempted gain per interation)
     
     #2) Load data, set seed
     series=np.genfromtxt(path,delimiter=',') # load as numpy array
-    seed=np.ones((series.shape[1],1)) # initialize seed
+    seed=np.ones((series.shape[1],1))/series.shape[1] # initialize seed
     bounds=[(0,1) for i in seed] # min and max boundary per weight
     
     #3) Create class and solve



More information about the Returnanalytics-commits mailing list