Learn R Programming

PortfolioTesteR (version 0.1.4)

run_walk_forward: Walk-Forward Optimization Analysis

Description

Runs rolling IS/OOS optimization, reselects params each window, and backtests OOS performance (optionally with warmup tails).

Usage

run_walk_forward(
  prices,
  grid,
  builder,
  metric = NULL,
  is_periods = 52,
  oos_periods = 13,
  step = NULL,
  warmup_periods = 0,
  verbose = FALSE,
  light_mode = TRUE,
  precompute_all = TRUE,
  builder_args = list(),
  n_cores = 1
)

Value

An object of class wf_optimization_result.

Arguments

prices

Data frame with Date column and symbol columns

grid

Data frame OR named list; each row/combination is a parameter set

builder

Function(prices, params, ...) -> weights data.frame (Date + assets)

metric

Function(backtest_result) -> scalar score (higher is better). Defaults to metric_sharpe if omitted/NULL.

is_periods

Integer, number of in-sample periods

oos_periods

Integer, number of out-of-sample periods

step

Integer, step size for rolling windows (default = oos_periods)

warmup_periods

Integer, warmup periods appended before each OOS

verbose

Logical, print progress

light_mode

Logical, passed to run_param_grid (kept for compatibility)

precompute_all

Logical, precompute indicators once and slice per window

builder_args

List, extra args passed to builder (e.g., indicator_cache)

n_cores

Integer (kept for API compatibility; ignored here)