
Last chance! 50% off unlimited learning
Sale ends in
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.
add.init(strategy, name, arguments, parameters = NULL, label = NULL,
..., enabled = TRUE, indexnum = NULL, store = FALSE)
an object (or the name of an object) of type 'strategy' to add the init function definition to
name of the init, must correspond to an R function
named list of default arguments to be passed to an init function when executed
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
arbitrary text label for init output, default NULL
any other passthru parameters
TRUE/FALSE whether the init is enabled for use in applying the strategy, default TRUE
if you are updating a specific init, the index number in the $init list to update
TRUE/FALSE whether to store the strategy in the .strategy environment, or return it. default FALSE
if strategy
was the name of a strategy, the name. It it was a strategy, the updated strategy.
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.