walk.forward: Rolling Walk Forward Analysis

Description Usage Arguments Details Value Author(s) See Also

Description

A wrapper for apply.paramset() and applyStrategy(), implementing a Rolling Walk Forward Analysis (WFA).

Usage

1
2
3
4
5
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)

Arguments

portfolio.st

the name of the portfolio object

account.st

the name of the account object

strategy.st

the name of the strategy object

paramset.label

a label uniquely identifying within the strategy the paramset to be tested

period

the period unit, as a character string, eg. 'days' or 'months'

k.training

the number of periods to use for training, eg. '3' months

nsamples

the number of sample param.combos to draw from the paramset for training; 0 means all samples (see also apply.paramset)

audit.prefix

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)

k.testing

the number of periods to use for testing, eg. '1 month'

obj.func

a user provided function returning the best param.combo from the paramset, based on training results; defaults to 'max'

obj.args

a user provided argument to obj.func, defaults to quote(tradeStats.list$Net.Trading.PL)

anchored

whether to use a fixed start for the training window (TRUE), or a sliding start (FALSE); defaults to FALSE

include.insamples

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

verbose

dumps a lot of info during the run if set to TRUE, defaults to FALSE

Details

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.

Value

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

Author(s)

Jan Humme

See Also

applyStrategy apply.paramset endpoints tradeStats


redmode/quantstrat documentation built on May 27, 2019, 4:04 a.m.