This function is the wrapper that holds together the execution of a strategy.
applyStrategy(strategy, portfolios, mktdata = NULL, parameters = NULL,
..., debug = FALSE, symbols = NULL, initStrat = FALSE,
updateStrat = FALSE, initBySymbol = FALSE, gc = FALSE,
delorders = FALSE, rule.subset = NULL, mdenv = NULL)
an object of type 'strategy' to add the indicator to
a list of portfolios to apply the strategy to
an xts object containing market data. depending on indicators, may need to be in OHLCV or BBO formats, default NULL
named list of parameters to be applied during evaluation of the strategy, default NULL
any other passthru parameters
if TRUE, return output list
character vector identifying symbols to initialize a portfolio for, default NULL
whether to use (experimental) initialization code, default FALSE
whether to use (experimental) wrapup code, default FALSE
whether to load and initialize each instrument within the Symbols
loop. See initSymbol
for details on how
to run a custom function. Moreover, if the argument Interval
is available (as passthrough to updatePortf
via updateStrat
),
each instrument is downsampled to the frequency specified by Interval
for the purpose of marking the Portfolio.
Notice that this happenes only after the strategy has been applied.
if TRUE, call gc
after each symbol run, default FALSE (experimental)
if TRUE, delete the order book for a symbol at the end of the symbols loop, will cause issues with rebalancing, default FALSE (experimental)
ISO-8601 subset for period to execute rules over, default NULL
environment to look in for market data, default NULL which expands to .GlobalEnv
After the straetgy object has been created, it may be applied to any combination of symbols and parameters.
The symbols to be utilized will be defined in one of two ways, either by
specifying a name of a portfolio that has already been initialized
with the portfolios
argument, or be specifying a
symbols
argument in addition to setting initStrat=TRUE
.
applyStrategy
will use the R core function get
to load market data for each symbol during stategy evaluation unless
the user passes mktdata
in the call to applyStrategy
strategy
, applyIndicators
,
applySignals
, applyRules
,
initStrategy
,