addToReport: Add statistic to report of strategy

View source: R/genericStrategy.R

addToReportR Documentation

Add statistic to report of strategy

Description

Add statistic to report of strategy

Usage

addToReport(this, ...)

## S3 method for class 'Strategy'
addToReport(this, ...)

Arguments

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

Examples

## 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)


Vitalic57/stratbuilder3gen documentation built on March 30, 2022, 6:58 a.m.