[Returnanalytics-commits] r2566 - pkg/PerformanceAnalytics/sandbox/pulkit/week1/code
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 13 21:54:11 CEST 2013
Author: pulkit
Date: 2013-07-13 21:54:10 +0200 (Sat, 13 Jul 2013)
New Revision: 2566
Modified:
pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R
Log:
Included the reference SR in the optimization
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R 2013-07-13 18:08:15 UTC (rev 2565)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R 2013-07-13 19:54:10 UTC (rev 2566)
@@ -101,12 +101,15 @@
SR = get_SR(stats,n)
meanSR = SR$meanSR
sigmaSR = SR$sigmaSR
+ if(refSR>meanSR){
+ stop("The Reference Sharpe Ratio should be less than the Observred Sharpe Ratio")
+ }
for(i in 1:columns){
d1Z[i] = get_d1Z(stats,m,meanSR,sigmaSR,mean,weights,i)
}
- dZ = list("d1Z"=d1Z,"z"=meanSR/sigmaSR)
+ dZ = list("d1Z"=d1Z,"z"=(meanSR-refSR)/sigmaSR)
return(dZ)
}
@@ -120,7 +123,7 @@
d1sigmaSR = (d1Kurt * meanSR^2+2*meanSR*d1meanSR*(stats[4]-1))/4
d1sigmaSR = d1sigmaSR-(d1Skew*meanSR+d1meanSR*stats[3])
d1sigmaSR = d1sigmaSR/(2*sigmaSR*(n-1))
- d1Z = (d1meanSR*sigmaSR-d1sigmaSR*meanSR)/sigmaSR^2
+ d1Z = (d1meanSR*sigmaSR-d1sigmaSR*(meanSR-refSR))/sigmaSR^2
return(d1Z)
}
@@ -191,7 +194,6 @@
return(sum/n)
}
weights = optimize()
- print(k)
result = matrix(weights,nrow = columns)
rownames(result) = columnnames
colnames(result) = "weight"
More information about the Returnanalytics-commits
mailing list