[R-SIG-Finance] Bug in PerformanceAnalytics 0.9.7.1
Bengoechea Bartolomé Enrique (SIES 73)
enrique.bengoechea at credit-suisse.com
Fri Jan 23 11:57:07 CET 2009
Hi,
I've hit a bug in PerformanceAnalytics 0.9.7.1: looks like the "sortDrawdowns()" function (usually invoked from "table.Drawdowns()") assumes that there's more than one drawdown, which is not necesarily the case.
Code to reproduce the bug:
> library(PerformanceAnalytics)
> x <- zoo(rep(-1, 5), seq(Sys.Date()-5, Sys.Date(), by="days"))
> table.Drawdowns(x)
Error in if (runs$return[j] > runs$return[j + 1]) { :
missing value where TRUE/FALSE needed
Proposed solution: check the number of drawdowns in parameter 'runs' of function "sortDrawdowns()" before looping. Just add the following line at the beginning of 'sortDrawdowns':
> if (length(runs$return) < 2) return(runs)
Tested on the following environment:
> sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32
locale:
LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] PerformanceAnalytics_0.9.7.1 zoo_1.5-4 rcom_2.0-4 rscproxy_1.0-12
loaded via a namespace (and not attached):
[1] grid_2.8.1 lattice_0.17-17 tools_2.8.1
Best,
Enrique
More information about the R-SIG-Finance
mailing list