Skip to main content
aifinhub

Worked example

Running the shipped walk-forward-validator engine on the input below produces exactly this output. Continuous integration recomputes it against the engine bundle on every build, so these numbers cannot drift from the code.

Input513 lines

{
  "tool": "walk-forward-validator",
  "returns": [
    -0.001963,
    -0.012479,
    0.001678,
    0.005818,
    0.002904,
    0.016199,
    -0.010215,
    -0.011291,
    -0.00885,
    0.011087,
    0.010352,
    -0.018134,
    -0.000351,
    -0.027556,
    0.013853,
    0.002829,
    0.01201,
    -0.005335,
    0.002408,
    -0.000679,
    -0.007028,
    -0.000491,
    0.008923,
    0.01677,
    -0.004295,
    -0.003625,
    0.01502,
    -0.008017,
    -0.014938,
    0.010538,
    -0.000181,
    -0.007533,
    0.000998,
    0.001664,
    0.020646,
    -0.010313,
    0.007983,
    0.000161,
    0.021717,
    -0.003661,
    0.004743,
    -0.016916,
    -0.00144,
    -0.002367,
    -0.00147,
    -0.008733,
    0.001381,
    0.001706,
    0.010257,
    -0.005394,
    0.011349,
    -0.00457,
    0.018437,
    0.006194,
    -0.014261,
    -0.010064,
    -0.000592,
    0.002704,
    -0.00545,
    -0.020481,
    0.000865,
    -0.015018,
    -0.000369,
    0.004206,
    0.020835,
    0.008116,
    -0.004725,
    -0.013077,
    0.002622,
    0.007969,
    0.006208,
    -0.002521,
    -0.003776,
    -0.003893,
    -0.014943,
    -0.002636,
    0.00064,
    -0.025395,
    0.000012,
    -0.004952,
    0.008274,
    0.004452,
    -0.012216,
    -0.002064,
    0.007842,
    0.014103,
    -0.008355,
    -0.015776,
    0.001045,
    0.020947,
    0.009039,
    -0.001656,
    0.000899,
    0.001202,
    0.00042,
    0.012725,
    0.011733,
    0.004129,
    0.003595,
    -0.001224,
    0.016571,
    -0.009856,
    0.014524,
    -0.002465,
    0.012585,
    -0.022801,
    0.001213,
    -0.008061,
    -0.000258,
    -0.003008,
    0.000886,
    0.010896,
    -0.00097,
    -0.01486,
    0.014959,
    0.006791,
    -0.004182,
    -0.012974,
    0.00402,
    -0.001335,
    0.000572,
    0.00246,
    0.00089,
    0.001763,
    -0.010631,
    -0.000107,
    -0.025486,
    0.018308,
    -0.004904,
    -0.004578,
    -0.000555,
    0.00095,
    0.010346,
    0.023064,
    0.001872,
    0.005515,
    -0.003406,
    -0.002496,
    -0.018304,
    -0.007502,
    0.00874,
    0.000996,
    0.00124,
    0.014657,
    0.009317,
    -0.00018,
    -0.001824,
    0.013271,
    -0.008061,
    0.002583,
    -0.012792,
    -0.004015,
    -0.008025,
    0.007647,
    0.004245,
    -0.010974,
    0.002517,
    0.005698,
    -0.002801,
    -0.003722,
    0.015448,
    -0.000347,
    -0.004969,
    0.007854,
    0.009593,
    0.008483,
    -0.006378,
    0.006256,
    -0.005028,
    0.002652,
    0.027214,
    0.003921,
    -0.015909,
    -0.002812,
    -0.0178,
    0.005756,
    -0.001616,
    -0.005424,
    -0.004348,
    0.016863,
    -0.00286,
    0.009739,
    -0.004282,
    0.006231,
    0.018314,
    0.007417,
    0.019838,
    0.010201,
    0.010844,
    0.010215,
    0.021008,
    0.002428,
    0.007751,
    0.011907,
    -0.008095,
    0.026528,
    0.003778,
    -0.008891,
    0.013017,
    -0.008592,
    0.008911,
    0.004709,
    0.012014,
    0.011634,
    -0.006732,
    -0.020783,
    0.000184,
    -0.00912,
    -0.008424,
    0.001358,
    -0.01852,
    -0.022151,
    0.00869,
    0.005651,
    0.00504,
    -0.011843,
    0.009225,
    -0.007563,
    0.007073,
    0.018178,
    -0.002588,
    -0.02005,
    -0.003395,
    -0.010913,
    0.018344,
    -0.016453,
    0.002408,
    0.020756,
    -0.005477,
    0.006213,
    0.00265,
    -0.011139,
    -0.013776,
    -0.002056,
    -0.000221,
    -0.017122,
    -0.015053,
    0.005493,
    0.015325,
    0.014373,
    0.000144,
    -0.00285,
    0.005115,
    0.026171,
    -0.005289,
    -0.015803,
    0.00196,
    0.000421,
    0.000596,
    -0.010572,
    0.001909,
    0.0117,
    0.007828,
    -0.001836,
    0.013003,
    0.001742,
    -0.007949,
    -0.016554,
    -0.00236,
    0.000244,
    0.021866,
    -0.005071,
    -0.005584,
    -0.016252,
    0.012277,
    0.006241,
    -0.004893,
    -0.007244,
    0.001554,
    0.012722,
    -0.001346,
    -0.008163,
    -0.013011,
    -0.011898,
    -0.006021,
    0.010052,
    0.023784,
    0.002652,
    -0.006692,
    -0.015492,
    0.004846,
    -0.007853,
    0.008334,
    0.010547,
    -0.000355,
    0.013627,
    -0.017681,
    0.008238,
    0.006914,
    -0.009842,
    0.008807,
    -0.008494,
    -0.00458,
    -0.018812,
    0.010621,
    -0.002476,
    0.000113,
    0.011247,
    -0.005866,
    0.000106,
    0.004621,
    0.001003,
    0.010875,
    -0.019995,
    0.00679,
    0.002305,
    -0.002696,
    -0.008726,
    0.006733,
    -0.001433,
    0.002676,
    0.020325,
    -0.012187,
    -0.00255,
    0.002901,
    -0.008843,
    -0.002478,
    -0.002239,
    -0.011717,
    -0.004133,
    -0.009637,
    0.005595,
    -0.009859,
    0.003201,
    0.003989,
    -0.013604,
    -0.003335,
    0,
    0.004707,
    -0.003641,
    0.008311,
    -0.009983,
    -0.0033,
    0.013249,
    0.005493,
    -0.005222,
    -0.000089,
    -0.001464,
    -0.007478,
    0.008983,
    -0.015762,
    0.006781,
    -0.0015,
    -0.003109,
    -0.003681,
    -0.001463,
    0.014056,
    -0.007641,
    -0.009482,
    -0.000922,
    0.003782,
    0.00393,
    0.000465,
    0.008987,
    0.006819,
    -0.020218,
    -0.01141,
    0.011072,
    0.006203,
    -0.000737,
    0.009408,
    0.001834,
    0.006954,
    0.007475,
    0.014111,
    0.004754,
    -0.003789,
    0.003102,
    0.007121,
    0.00311,
    0.008445,
    -0.014787,
    -0.015603,
    0.01063,
    -0.000421,
    -0.000965,
    0.01096,
    -0.009481,
    0.01617,
    0.021536,
    0.013751,
    -0.001799,
    0.007637,
    0.002021,
    0.015693,
    -0.010612,
    0.002416,
    -0.004587,
    -0.003785,
    -0.009463,
    -0.022902,
    -0.006746,
    0.00795,
    0.001794,
    -0.012557,
    -0.022758,
    0.002901,
    -0.007373,
    0.008675,
    0.01275,
    -0.010448,
    0.023442,
    0.00614,
    -0.001848,
    0.004913,
    -0.009453,
    -0.003378,
    0.000054,
    -0.003948,
    -0.01194,
    0.003708,
    0.0007,
    -0.006101,
    0.000456,
    -0.00847,
    0.025746,
    -0.003852,
    -0.036062,
    0.00377,
    -0.008647,
    0.004019,
    -0.001825,
    0.008475,
    0.008483,
    -0.019366,
    0.0007,
    -0.002969,
    -0.007622,
    -0.022445,
    -0.01142,
    0.008933,
    -0.00202,
    -0.011522,
    0.002611,
    0.015917,
    -0.003327,
    -0.008393,
    -0.009948,
    0.005769,
    0.009727,
    -0.021601,
    -0.000128,
    0.010065,
    -0.004138,
    0.003234,
    0.003487,
    0.012028,
    0.008942,
    0.016704,
    -0.019694,
    -0.020774,
    0.002391,
    -0.004847,
    0.020564,
    0.003117,
    0.01344,
    -0.005059,
    0.016582,
    -0.005442,
    0.020337,
    0.011846,
    -0.005612,
    0.005714,
    -0.017366,
    -0.000424,
    0.010079,
    -0.010446,
    -0.002289,
    0.004748,
    -0.005261,
    0.001651,
    0.004862,
    0.009383,
    0.003789,
    0.001858,
    0.004966,
    -0.012115,
    0.006609,
    -0.001566,
    -0.019978,
    0.001681,
    0.002556,
    0.003041,
    -0.00071,
    0.023267,
    0.010219,
    0.022246,
    -0.002453,
    -0.006633,
    -0.003383,
    -0.01549,
    0.000828,
    0.008374,
    -0.005278,
    0.002477,
    -0.005417,
    0.001817,
    0.006532,
    -0.002944,
    -0.011195,
    -0.005382,
    0.001508,
    0.012814,
    -0.014852
  ],
  "is_len": 252,
  "oos_len": 63,
  "step": 63,
  "mode": "rolling"
}

Output48 lines

{
  "windows": [
    {
      "index": 0,
      "isStart": 0,
      "isEnd": 252,
      "oosStart": 252,
      "oosEnd": 315,
      "isSharpe": 1.0370415589969475,
      "oosSharpe": 0.04214258756321766,
      "oosReturn": -0.0014504410192713868
    },
    {
      "index": 1,
      "isStart": 63,
      "isEnd": 315,
      "oosStart": 315,
      "oosEnd": 378,
      "isSharpe": 1.1948138381451516,
      "oosSharpe": -0.4451484542010896,
      "oosReturn": -0.016414662344676367
    },
    {
      "index": 2,
      "isStart": 126,
      "isEnd": 378,
      "oosStart": 378,
      "oosEnd": 441,
      "isSharpe": 0.9498677865002498,
      "oosSharpe": -1.7573662369190102,
      "oosReturn": -0.08306833893099486
    },
    {
      "index": 3,
      "isStart": 189,
      "isEnd": 441,
      "oosStart": 441,
      "oosEnd": 504,
      "isSharpe": -0.3329028873075593,
      "oosSharpe": 2.0971477694444314,
      "oosReturn": 0.08502743961050307
    }
  ],
  "nWindows": 4,
  "meanIsSharpe": 0.7122050740836975,
  "meanOosSharpe": -0.015806083528112636,
  "efficiency": -0.02219316332230332
}

Frequently asked questions

What does the Walk-Forward Validator methodology page document?
Formal definition of walk-forward validation, rolling vs expanding windows, efficiency ratio, and limitations. It states the formulas, assumptions, data sources, limitations, and reproducibility steps behind the Walk-Forward Validator, in the Finance category.
When was the Walk-Forward Validator methodology last reviewed?
This methodology was last reviewed on 2026-04-20. The matching tool is at https://aifinhub.io/walk-forward-validator/.
Are the Walk-Forward Validator numbers reproducible?
Yes. This page embeds a worked example whose output is the verbatim result of running the shipped walk-forward-validator engine on a fixed input; the embedded JSON is recomputed and diffed against the engine in CI, so the numbers cannot drift from the code.

Methodology · Playground · Last updated 2026-04-20

How Walk-Forward Validator works

How the Walk-Forward Validator tool actually works — assumptions, algorithms, limitations.

Definitions

IS (in-sample) window: a contiguous slice of observations used to fit / select / validate a strategy's parameters.

OOS (out-of-sample) window: the contiguous slice immediately following IS, used to measure real-world performance of the IS-fitted strategy.

Walk-forward: slide IS and OOS windows forward by step observations; repeat.

Modes

  • Rolling: IS window has fixed length; the start and end both slide forward each step. Useful when regime changes matter and the model should only remember recent history.
  • Expanding: IS always starts at t=0; only the end advances. Useful when more history is always better (e.g. risk model calibration).

Metrics reported

  • Per-window IS Sharpe: annualized Sharpe on the IS slice (for reference only — we don't optimize on it here).
  • Per-window OOS Sharpe: annualized Sharpe on the OOS slice.
  • Per-window OOS return: cumulative total return over the OOS slice.
  • Aggregate OOS Sharpe: Sharpe computed over the concatenation of all OOS slices. This is the single most-representative metric of what you'd see live.
  • Walk-forward efficiency ratio: mean(OOS Sharpe) / mean(IS Sharpe). Higher is better. Values below 0.4 are a strong overfitting signal.
  • OOS losing windows: count of windows with OOS Sharpe < 0.

Verdict bands

SignalInterpretation
Aggregate OOS Sharpe < 0.3Weak OOS — edge does not persist.
WF efficiency < 0.4IS/OOS degradation — likely overfit.
0.4 ≤ WF efficiency < 0.7Some decay; inspect per-window consistency.
WF efficiency ≥ 0.7Strong walk-forward.

Limitations

  1. No embargoed purging. For strategies with features that include lagged information (moving averages spanning IS/OOS boundary), a purged K-fold or embargo is more appropriate. This tool does a pure sequential walk; use Lopez de Prado's Advances in Financial Machine Learning Chapter 7 for proper purging.
  2. Assumes the returns series is post-all-model-selection. If you re-optimize parameters per window, this tool cannot see that — the provided returns should reflect actual walk-forward trading.
  3. Step selection. Step sizes smaller than OOS length produce overlapping windows, inflating apparent sample size. Default step = OOS length for non-overlapping slices.
  4. Transaction costs. The returns series is used as-is. If you upload gross returns, efficiency will overstate live performance.
  5. Non-stationary markets. If the underlying process changes, even a perfect walk-forward will show degradation. That's a feature, not a bug — but don't confuse regime change with overfitting.

Connects to

References

  • Lopez de Prado, M. (2018). Advances in Financial Machine Learning, Chapter 7.
  • Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies.
  • Bailey, D. H., & Lopez de Prado, M. (2014). "The Deflated Sharpe Ratio."

External resources

Changelog

  • 2026-04-20 — Initial release.