add.init: add arbitrary initialization functions to a strategy

Description Usage Arguments Details Value

View source: R/initialize.R

Description

initStrategy will run a series of common initialization functions at the beginning of an applyStrategy call. This function allows the user to add arbitrary initialization functions to the sequence.

Usage

1
2
add.init(strategy, name, arguments, parameters = NULL, label = NULL, ...,
  enabled = TRUE, indexnum = NULL, store = FALSE)

Arguments

strategy

an object (or the name of an object) of type 'strategy' to add the init function definition to

name

name of the init, must correspond to an R function

arguments

named list of default arguments to be passed to an init function when executed

parameters

vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision

label

arbitrary text label for init output, default NULL

...

any other passthru parameters

enabled

TRUE/FALSE whether the init is enabled for use in applying the strategy, default TRUE

indexnum

if you are updating a specific init, the index number in the $init list to update

store

TRUE/FALSE whether to store the strategy in the .strategy environment, or return it. default FALSE

Details

These arbitrary functions will be added to the init slot of the strategy object and when applyStrategy is evaluated, the arbitrary initialization functions will be evaluated after the standardized functions.

For example, if your strategy uses a synthetic basket instrument, you could use this initialization slot to add a custom constructor to build the basket instrument time series and modify the symbols slot(s) of the strategy and portfolio.

Value

if strategy was the name of a strategy, the name. It it was a strategy, the updated strategy.


cloudcell/quantstrat documentation built on May 13, 2019, 8:03 p.m.