[Returnanalytics-commits] r2544 - pkg/PerformanceAnalytics/sandbox/pulkit/week3/code
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 11 21:54:42 CEST 2013
Author: pulkit
Date: 2013-07-11 21:54:41 +0200 (Thu, 11 Jul 2013)
New Revision: 2544
Added:
pkg/PerformanceAnalytics/sandbox/pulkit/week3/code/chart.Penance.R
Log:
Added chart for penance vs phi
Added: pkg/PerformanceAnalytics/sandbox/pulkit/week3/code/chart.Penance.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week3/code/chart.Penance.R (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week3/code/chart.Penance.R 2013-07-11 19:54:41 UTC (rev 2544)
@@ -0,0 +1,29 @@
+#'@title
+#'Penance vs phi plot
+#'
+#'A plot for Penance vs phi for the given portfolio
+#'
+#'@param R an xts, vector, matrix, data frame,
+#'timeSeries or zoo object of asset returns.
+#'@param confidence the confidence level
+#'
+#'@reference Bailey, David H. and Lopez de Prado, Marcos,Drawdown-Based Stop-Outs and the ‘Triple Penance’ Rule(January 1, 2013).
+
+chart.Penance<-function(R,confidence,...){
+ x = checkData(R)
+ columns = ncol(x)
+ columnnames = colnames(x)
+ phi = 1:columns
+ penance = 1:columns
+ for(column in 1:columns){
+ phi[column] = cov(x[,column][-1],x[,column][-length(x[,column])])/(cov(x[,column][-length(x[,column])]))
+ penance[column]<-get_minq(x[,column],confidence)[1]/get_TuW(x[,column],confidence)
+ }
+ plot(x=phi,y=penance,xlab="Phi",ylab = "Penance",main="Penance vs Phi")
+ text(phi,penance,columnnames,pos = 4)
+}
+
+
+
+
+
More information about the Returnanalytics-commits
mailing list