walk_forwardValidate strategy robustness across sequential out-of-sample windows.
Area
Backtesting & Validation
Group
Robustness
Access
Write
Risk
May change server state
Details
Full description
Details
Run a walk-forward analysis to validate strategy robustness out-of-sample. Walk-forward divides a historical period into N sequential windows and backtests each to measure consistency across regimes.
Workflow
walk_forward(strategy_id, total_lookback="1yr", windows=5) # → walk_forward_id
get_walk_forward(walk_forward_id) # poll until completed
Level 1 (consistency check) — no sweep; runs the strategy as-is on each window. Reports oos_sharpe_mean, oos_sharpe_std, pct_profitable_windows. High mean + low std = robust across regimes; pct_profitable_windows > 0.75 is strong, < 0.5 is concerning.
Level 2 (rolling re-optimization) — requires a sweep config. Each window splits into in-sample (IS) and out-of-sample (OOS): the sweep runs on IS, params are selected by select_by (default sharpe), then applied to the OOS period. Reports Walk-Forward Efficiency (WFE = OOS Sharpe / IS Sharpe: > 0.5 strong, 0.3–0.5 acceptable, < 0.3 suggests overfitting) plus parameter stability — params that hold steady across windows suggest real signal.
Portfolios — pass portfolio_id instead of strategy_id. Portfolio walk-forward is Level 1 only (one coupled backtest per window with a per-member breakdown); it does not support sweep / overrides / oos_pct / select_by.
Key params — total_lookback (e.g. "1yr", "2yr", "6mo"), windows (default 5), mode (rolling or anchored, default rolling), oos_pct (Level 2, default 0.3), initial_cash (default 100000), fee_pct / slippage_pct (default 0; fee auto-detected by asset class).
Capabilities
Bounded options and operating modes surfaced above the full JSON schema.
Required Inputs
Optional Inputs
benchmark_symbolanyOf (2 variants)Optional secondary market-index benchmark (e.g. 'SPY'). When set, each window's child backtest reports market_benchmark_* fields alongside the per-symbol buy-and-hold benchmark.fee_pctanyOf (2 variants)Trading fee as percentage (0.1 = 0.1%). None=auto-detect (equities=0.00%; crypto/mixed=0.50%). Set 0 for zero fees.initial_cashnumberInitial cash for each backtest windowmodestringWindow layout: 'rolling' (each window shifts forward by one window length) or 'anchored' (IS start is fixed, OOS end advances). Default: rollingoos_pctnumberFraction of each window reserved for out-of-sample testing (Level 2 only). 0.25 = 25%% OOS, 75%% IS. Default: 0.25overridesanyOf (2 variants)Optional strategy-wide per-run override patch, applied to EVERY child window backtest (same shape as run_backtest overrides — distinct from sweep's per-variant 'overrides'). Example: {"sizing":{"mode":"fixed_usd","fixed_usd":5000},"execution":{"order_type":"market"}}portfolio_idanyOf (2 variants)Portfolio identifier to analyze. Mutually exclusive with strategy_id. Portfolio walk-forward is Level 1 only (no sweep / overrides / oos_pct / select_by).select_bystringMetric used to select the parameter set in each IS window (Level 2). Options: 'sharpe_ratio', 'sortino_ratio', 'total_pnl_pct', 'win_rate'. Default: sharpe_ratio.slippage_pctanyOf (2 variants)Slippage as percentage (0.05 = 0.05%). None=auto-detect (equities=0.01%; crypto/mixed=0.05%). Set 0 for zero slippage.strategy_idanyOf (2 variants)Strategy identifier to analyze. Mutually exclusive with portfolio_id.sweepanyOf (2 variants)Parameter sweep config for Level 2 re-optimization. Same format as run_backtest sweep. Example: {"mode": "cartesian", "overrides": {"conditions": [{"label": "entry.rsi", "patch": {"type": "rsi", "threshold": [25, 30, 35]}}]}}total_lookbackstringTotal historical window for the analysis: '1yr', '2yr', '6mo', etc. This is divided into N windows. Longer lookbacks give more windows but require more data. Default: 2yrwindowsintegerNumber of time windows to divide the lookback into. Default: 6