A wrapper for apply.paramset() and applyStrategy(), implementing a Rolling Walk Forward Analysis (WFA).
walk.forward(strategy.st, paramset.label, portfolio.st, account.st, period,
k.training, nsamples = 0, audit.prefix = NULL, k.testing,
obj.func = function(x) { which(x == max(x)) }, obj.args = list(x =
quote(tradeStats.list$Net.Trading.PL)), anchored = FALSE,
include.insamples = TRUE, ..., verbose = FALSE)
the name of the strategy object
a label uniquely identifying within the strategy the paramset to be tested
the name of the portfolio object
the name of the account object
the period unit, as a character string, eg. 'days' or 'months'
the number of periods to use for training, eg. '3' months
the number of sample param.combos to draw from the paramset for training; 0 means all samples (see also apply.paramset)
prefix to generate filenames for storage of audit data. For each training set, a separate file is created, containing an enviroment called .audit, with all in-sample portfolios and orderbooks as well as information as to which param.combos were evaluated, and the result of the objective function. In addition, a special file is generated that contains portfolio and orderbook for the concatenated testing param.combos as selected by the objective function, plus (optionally) complete in-sample portfolios and orderbooks for reference (see include.insamples)
the number of periods to use for testing, eg. '1 month'
a user provided function returning the best param.combo from the paramset, based on training results; defaults to 'max'
a user provided argument to obj.func, defaults to quote(tradeStats.list$Net.Trading.PL)
whether to use a fixed start for the training window (TRUE), or a sliding start (FALSE); defaults to FALSE
will optionally run a full backtest for each param.combo in the paramset, and add the resulting in-sample portfolios and orderbooks to the file '<prefix>.results.RData'; default TRUE
optional parameters to pass to apply.paramset()
dumps a lot of info during the run if set to TRUE, defaults to FALSE
a list consisting of a slot containing detailed results for each training + testing period, as well as the portfolio and the tradeStats() for the portfolio
walk.forward executes a strategy on a portfolio, while rolling a re-optimization of one of the strategies parameter sets during a specified time period (training window), then selecting an optimal parameter combination from the parameter set using an obj function, then applying the selected parameter combo to the next out-of-sample time period immediately following the training window (testing window). Once completed, the training window is shifted forward by a time period equal to the testing window size, and the process is repeated. WFA stops when there are insufficient data left for a full testing window.
For a complete description, see Jaekle&Tomasini chapter 6.
applyStrategy
,
apply.paramset
,
chart.forward
,
chart.forward.training
,
endpoints
,
tradeStats