View source: R/genericStrategy.R
| addToReport | R Documentation |
Add statistic to report of strategy
addToReport(this, ...) ## S3 method for class 'Strategy' addToReport(this, ...)
this |
Strategy |
... |
Stats or function objects. Function should have arguments as follows function(this, start, end), where this - Strategy start - numeric index of starting point end - numeric index of ending point |
## Not run:
addToReport(this, Stats$sharpe, double_sharpe=function(this, start, end){
pnl <- getPnL(this)
dates <- getDateByIndex(this, c(start, end))
pnl <- pnl[paste0(dates[1], '/', dates[2])]
sharpes <- rollapply(diff(pnl), width = 252, FUN=SharpeRatio.mean, by=30, align='right') %>% na.omit
sharpes %>% {mean(.) / sd(.) * sqrt(12)}
})
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.