[Returnanalytics-commits] r2443 - in pkg/PerformanceAnalytics/sandbox/pulkit: week1/vignette week2/code
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 26 16:54:06 CEST 2013
Author: pulkit
Date: 2013-06-26 16:54:05 +0200 (Wed, 26 Jun 2013)
New Revision: 2443
Modified:
pkg/PerformanceAnalytics/sandbox/pulkit/week1/vignette/ProbSharpe.Rnw
pkg/PerformanceAnalytics/sandbox/pulkit/week2/code/BenchmarkSR.R
Log:
Added vignette for Benchmark SR
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week1/vignette/ProbSharpe.Rnw
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/vignette/ProbSharpe.Rnw 2013-06-26 12:40:38 UTC (rev 2442)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/vignette/ProbSharpe.Rnw 2013-06-26 14:54:05 UTC (rev 2443)
@@ -33,6 +33,7 @@
<<echo = FALSE >>=
library(PerformanceAnalytics)
+data(edhec)
@
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week2/code/BenchmarkSR.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week2/code/BenchmarkSR.R 2013-06-26 12:40:38 UTC (rev 2442)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week2/code/BenchmarkSR.R 2013-06-26 14:54:05 UTC (rev 2443)
@@ -13,21 +13,30 @@
#'@param R a vector, matrix, data frame,timeseries or zoo object of asset returns
#'
#'@references
+#'Bailey, David H. and Lopez de Prado, Marcos, The Strategy Approval Decision:
+#'A Sharpe Ratio Indifference Curve Approach (January 2013). Algorithmic Finance,
+#'Vol. 2, No. 1 (2013).
#'
+#'@examples
+#'
+#'data(edhec)
+#'BenchmarkSR(edhec) #expected 0.2019308
+#'
#'@export
+#'
BenchmanrkSR<-function(R){
-
x = checkData(R)
columns = ncol(x)
SR = SharpeRatio(x)
sr_avg = mean(SR)
corr = table.Correlation(edhec,edhec)
corr_avg = 0
- for(i in 1:columns){
- for(j in i:columns){
+ for(i in 1:(columns-1)){
+ for(j in (i+1):columns){
corr_avg = corr_avg + corr[(i-1)*columns+j,]
}
}
+ corr_avg = corr_avg*2/(columns*(columns-1))
SR_Benchmark = sr_avg*sqrt(columns/(1+(columns-1))*corr_avg[1,1])
return(SR_Benchmark)
}
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list