Rolling optimization: walk-forward portfolio backtest
Rolling (walk-forward) optimization re-estimates a portfolio’s optimal weights at each rebalance date using only a trailing window of past data, holds them until the next date and repeats, so its track record contains no look-ahead and measures how an optimisation method performs out of sample. This free tool runs it on real monthly ETF returns for maximum Sharpe, minimum volatility and risk parity, against equal weights and the optimum picked with hindsight. No sign-up.
Data updated November 13, 2026
Short answer. Rolling (walk-forward) optimisation re-optimises a portfolio at each rebalance date using only a trailing window of past data and holds the weights until the next date, so every month of the result is out of sample. For SPY, EFA, AGG, TLT and GLD, with a 60-month window, quarterly rebalancing and 10 basis points per trade, maximum-Sharpe weights had an average Sharpe ratio of 1.33 on the windows they were chosen from and delivered 0.69 from Jun 2012 to Oct 2026. Equal weights, rebalanced on the same dates, delivered 0.62, and the single maximum-Sharpe mix picked with hindsight (79% SPY and 21% GLD) 1.00. Minimum volatility went from 0.75 in-sample to 0.16 out of sample, and risk parity from 0.84 to 0.55.
- Max Sharpe: Sharpe in-sample
- 1.33
- Max Sharpe: Sharpe out-of-sample
- 0.69
- Equal weight: Sharpe
- 0.62
- Max Sharpe with hindsight
- 1.00
- Max Sharpe: return a year
- +7.9%
- Max Sharpe: turnover a year
- 53%
- Min volatility: in / out Sharpe
- 0.75 / 0.16
- Risk parity: in / out Sharpe
- 0.84 / 0.55
Monthly total returns with dividends reinvested; first data month Jun 2007, test Jun 2012 to Oct 2026 (173 months; prices to November 13, 2026). 60-month window, quarterly rebalancing, 10 bps per trade, weights 0–100%. Sharpe ratios on excess returns over 1–3 month US Treasury bills (BIL). Historical test, not a forecast or a recommendation.
1 · Funds and weight limits
2 · Objective, re-optimised at every rebalance
3 · Window, rebalancing and costs
Sharpe, out-of-sample
0.69
Walk-forward, realised
Sharpe, in-sample
1.33
Average over the windows
Gap (in − out)
0.64
Promised but not delivered
Equal weight Sharpe
0.62
Hindsight optimum: 1.00
Test period Jun 2012 to Oct 2026 (173 months, after the first 60-month window from Jun 2007); 59 optimisations.
| Walk-forward Max Sharpeout-of-sample | Equal weight (1/N)same schedule | Max Sharpe with hindsight in-sample | |
|---|---|---|---|
| Return a year (CAGR) | +7.9% | +6.7% | +13.4% |
| $10,000 became | $29,803 | $25,446 | $61,451 |
| Volatility | 9.4% | 8.4% | 11.7% |
| Sharpe ratio, realised | 0.69 | 0.62 | 1.00 |
| Sharpe ratio, in-sample promise | 1.33 | — | 0.99 |
| Max drawdown | −23.7% | −21.1% | −21.0% |
| Turnover a year | 53% | 8% | 5% |
| Cost drag | 0.11% | 0.02% | 0.01% |
All three are rebalanced on the same dates and pay the same cost on the value bought and sold. The hindsight column holds one fixed mix (79.3% SPY, 20.7% GLD) chosen by looking at every month of the test: nobody could have held it, so read it as an upper reference. Sharpe ratios use US Treasury bills (BIL) .
Growth of $10,000, out of sample
How the weights changed
Weights held at the start of each month, after any rebalance. Between rebalances they drift with prices. Hover for the month.
The bands add up to 100% each month.
Average one-way turnover per rebalance: 13.2%; 53% a year, which at the cost you set took 0.11% a year from the return.
Each optimisation
Newest first. The in-sample Sharpe is what the chosen weights achieved on the window they were chosen from.
| Held from | SPY | EFA | AGG | TLT | GLD | In-sample Sharpe | Turnover |
|---|---|---|---|---|---|---|---|
| Oct 2026window to Sep 2026 | 43.7% | 0.0% | 0.0% | 0.0% | 56.3% | 1.02 | 2.2% |
| Jul 2026window to Jun 2026 | 41.7% | 0.0% | 0.0% | 0.0% | 58.3% | 1.00 | 6.1% |
| Apr 2026window to Mar 2026 | 29.1% | 0.0% | 0.0% | 0.0% | 70.9% | 1.20 | 8.3% |
| Jan 2026window to Dec 2025 | 40.5% | 0.0% | 0.0% | 0.0% | 59.5% | 1.18 | 6.4% |
| Oct 2025window to Sep 2025 | 49.0% | 0.0% | 0.0% | 0.0% | 51.0% | 1.15 | 2.4% |
| Jul 2025window to Jun 2025 | 53.2% | 0.0% | 0.0% | 0.0% | 46.8% | 1.06 | 0.2% |
| Apr 2025window to Mar 2025 | 52.2% | 0.0% | 0.0% | 0.0% | 47.8% | 1.14 | 10.2% |
| Jan 2025window to Dec 2024 | 47.4% | 0.0% | 0.0% | 0.0% | 52.6% | 0.86 | 2.1% |
| Oct 2024window to Sep 2024 | 48.8% | 0.0% | 0.0% | 0.0% | 51.2% | 0.95 | 3.4% |
| Jul 2024window to Jun 2024 | 53.9% | 0.0% | 0.0% | 0.0% | 46.1% | 0.87 | 3.5% |
| Apr 2024window to Mar 2024 | 50.4% | 0.0% | 0.0% | 0.0% | 49.6% | 0.89 | 6.6% |
| Jan 2024window to Dec 2023 | 56.3% | 0.0% | 0.0% | 0.0% | 43.7% | 0.88 | 16.4% |
Monthly total returns with dividends reinvested, complete months only; the funds’ own costs are included, taxes are not. Each set of weights uses only data available at the end of the month before it is held. A historical test, not a forecast and not investment advice.
Four objectives, walk-forward on the same months
Each objective re-optimised on the trailing 60 months, quarterly, with 10 bps per trade and weights between 0% and 100%, on SPY, EFA, AGG, TLT and GLD over the same months, Jun 2012 to Oct 2026. The tool above reproduces any row.
| Objective | Sharpe in-sample | Sharpe out-of-sample | Gap | Return a year | Volatility | Max drawdown | Turnover a year | Sharpe with hindsight |
|---|---|---|---|---|---|---|---|---|
| Maximum Sharpe ratio | 1.33 | 0.69 | 0.64 | +7.9% | 9.4% | −23.7% | 53% | 1.00 |
| Minimum volatility | 0.75 | 0.16 | 0.59 | +2.3% | 4.7% | −16.6% | 4% | 0.04 |
| Risk parity (equal risk contribution) | 0.84 | 0.55 | 0.29 | +5.5% | 7.3% | −19.8% | 9% | 0.55 |
| Equal weight | 0.72 | 0.62 | 0.10 | +6.7% | 8.4% | −21.1% | 8% | 0.62 |
In-sample: the average Sharpe ratio each set of weights had on its own window. Out-of-sample: the realised Sharpe ratio of the walk-forward portfolio, net of costs. Gap = in − out. The equal-weight row rebalances to 1/N on the same dates (Sharpe 0.62, return +6.7% a year); its in-sample figure is simply how 1/N did on each trailing window. With hindsight: one fixed mix optimised on all the test months.
What is rolling (walk-forward) optimization?
A portfolio optimiser turns estimates of returns, volatilities and correlations into weights. Run once on all the data you have, it answers a question about the past: which mix would have done best over those years. Rolling optimisation asks the question an investor actually faces: if I had used this method, with the data available at each point, what would I have earned?
The procedure is mechanical. Pick an estimation window, say 60 months. At the first rebalance date, optimise on the 60 months that end there and buy the result. Hold it, letting the weights drift with prices, until the next rebalance date; then move the window forward, optimise again and trade to the new weights, paying costs on what changes. Chaining the months held produces an equity curve in which every return was earned with weights decided beforehand. The method behind the weights is the same as in the portfolio optimizer: mean-variance in the tradition of Markowitz [1], minimum volatility and risk parity [6].
The term walk-forward comes from the testing of trading systems, where a rule’s parameters are re-fitted on each window and judged on the next. Applied to allocation, the parameters are the weights themselves.
Why walk-forward is the honest test of optimisation
Optimised portfolios usually look excellent on the data they were optimised on, by construction: the optimiser searched every mix and kept the one that scored best on those months, including on their noise. Average returns are the noisiest input; Chopra and Ziemba found errors in expected returns about ten times as damaging as errors in variances [4], and Michaud called mean-variance optimisers “estimation-error maximizers” [3].
A single split into a fitting half and a test half, as in our optimiser, already exposes this. Walk-forward goes further: it re-fits many times, so the result does not hinge on one split, and it includes what re-fitting costs, the turnover from weights that chase the latest window. On the default funds, maximum-Sharpe weights promised an average Sharpe ratio of 1.33 on their windows and delivered 0.69; with hindsight the best fixed mix reached 1.00, and plain equal weights 0.62.
The benchmark that matters is equal weight. DeMiguel, Garlappi and Uppal tested 14 optimisation models on seven datasets with rolling estimation windows and found none that consistently beat the 1/N portfolio out of sample on Sharpe ratio, certainty-equivalent return or turnover [2]. They estimated that sample-based mean-variance would need around 3,000 months of data with 25 assets to beat it reliably. If a method cannot beat 1/N in your walk-forward test, the optimisation is adding trading and complexity without evidence of value.
A walk-forward test is not immune to over-fitting either. Trying many windows, frequencies and fund lists and keeping the best one fits the test itself; Bailey, Borwein, López de Prado and Zhu show how quickly the best of many backtests stops meaning anything [7]. Decide the settings first, then run the test.
How the backtest works
window at decision t: months t−W … t−1 (W = estimation window) estimates: μ = mean excess return × 12, Σ = covariance × 12 weights: w_t = argmax objective(μ, Σ) within min/max limits held: months t … next rebalance, drifting with returns trade at rebalance: traded = Σ |w_new − w_drifted| cost: value × (1 − bps/10,000 × traded) turnover (one-way): traded / 2, averaged per year in-sample Sharpe: Sharpe of w_t on its own window (what was promised) out-of-sample Sharpe: Sharpe of the chained net monthly returns
Data. Monthly total returns with dividends reinvested, net of each fund’s fees, on the months all chosen funds and the T-bill series share. Excess returns are over the BIL Treasury-bill ETF for US-dollar funds and XEON for euro funds. Only complete months are used.
Rebalance dates. The first decision is taken as soon as one full window exists; after that, at every month-end (monthly), at the end of March, June, September and December (quarterly) or every December (annual). The decision uses the window that ends at that month-end and earns the returns of the following months.
Objectives. The same solvers as the optimiser: maximum Sharpe along the efficient frontier, minimum variance as an exact quadratic programme, equal risk contribution by coordinate descent, and equal weight within your limits. With no feasible mix the tool says so.
Benchmarks. Equal weight (1/N) is rebalanced on the same dates at the same cost. The hindsight optimum is the same objective estimated on all the test months, held as one fixed mix with the same rebalancing and costs: it is in-sample by construction.
How to read the results
In-sample vs out-of-sample Sharpe. The first is the average Sharpe ratio each set of weights had on the window it was picked from; the second is what the walk-forward portfolio earned. A large positive gap means the optimiser was fitting noise. A small or negative gap is typical of objectives that do not use average returns.
Against equal weight. Same funds, same dates, same costs, no estimates. Beating it on Sharpe ratio after costs is the minimum for an optimisation method to earn its complexity.
Against the hindsight optimum. The distance between the walk-forward line and the hindsight line is the price of not knowing the future. It is not a target: no rule can reach it reliably.
Weights over time and turnover. Stable bands mean the method’s view of the funds changed little from one window to the next; bands that jump between funds mean each window told a different story. High turnover multiplies costs and, in a taxable account, realised gains.
Worked example: walk-forward maximum Sharpe on SPY, EFA, AGG, TLT and GLD
The default run, step by step: a 60-month window, quarterly rebalancing at quarter-ends, 10 bps per trade, weights between 0% and 100%. The numbers match the short answer and the tool above.
- Line up the data. The funds and the T-bill series share monthly total returns from Jun 2007, so the first window covers Jun 2007 to May 2012 and nothing after it.
- First decision, at the end of May 2012: estimate average excess returns and the covariance matrix on those 60 months and find the maximum Sharpe mix: 86% AGG, 12% GLD and 1% TLT. On its own window that mix had a Sharpe ratio of 1.15. It is held from Jun 2012.
- Hold and drift. Until the next quarter-end the weights move with prices (rebalancing follows calendar quarter-ends, so this first holding period is shorter). At the end of Jun 2012 the window moves forward and the optimiser picks 88% AGG and 12% GLD; trading from the drifted weights to the new ones turns over 1.7% of the portfolio one way and costs 10 bps on the value bought and sold.
- Repeat. Over 59 optimisations the in-sample Sharpe ratio of the chosen weights ranged from 0.58 to 2.43, an average of 1.33. The largest holding was at different times AGG, SPY, TLT and GLD, and 46 of the 59 decisions (78%) put half the portfolio or more in one fund. Average one-way turnover per rebalance was 13.2%, 53% a year. The latest decision, at the end of Sep 2026, was 56% GLD and 44% SPY.
- Chain the months. From Jun 2012 to Oct 2026 the walk-forward portfolio returned +7.9% a year after costs (+8.0% before), with a volatility of 9.4%, a Sharpe ratio of 0.69 and a maximum drawdown of −23.7%.
- Compare. Equal weights on the same dates and costs: +6.7% a year, Sharpe 0.62, maximum drawdown −21.1%. The fixed maximum-Sharpe mix chosen with hindsight (79% SPY and 21% GLD): +13.4% a year and Sharpe 1.00, a figure nobody could have earned because it needed the answer in advance.
- Measure the gap. The optimiser promised 1.33 and delivered 0.69: 0.64 of Sharpe ratio lost between the window and the months that followed.
To see why the weights swing, put the same funds in the portfolio optimizer and change the period: the maximum-Sharpe mix moves with every few months of data, which is exactly what the walk-forward test pays for.
Choosing the estimation window
The window sets how much history each decision rests on. With 36 months, a single strong year is a third of the evidence; with 120, regimes from a decade ago still count. The table runs the default maximum Sharpe test with three windows; longer windows start later, so each has its own test period and its own equal-weight comparison.
| Window | Test period | Sharpe in-sample | Sharpe out-of-sample | Equal weight | Turnover a year |
|---|---|---|---|---|---|
| 36 months | Jun 2010 to Oct 2026 | 1.52 | 0.81 | 0.72 | 64% |
| 60 months | Jun 2012 to Oct 2026 | 1.33 | 0.69 | 0.62 | 53% |
| 120 months | Jun 2017 to Oct 2026 | 1.15 | 0.69 | 0.55 | 29% |
Read the out-of-sample column against equal weight in the same row, not across rows. A window that wins only over one test period is a parameter fitted to history.
How to run a walk-forward optimisation test in 7 steps
- 1
Choose the funds and limits
Pick 2 to 8 ETFs with long histories and set a minimum and maximum weight per fund. Long-only is the default.
- 2
Choose the objective
Maximum Sharpe, minimum volatility or risk parity, or equal weight as the no-estimate baseline. Start with the one you would use in practice.
- 3
Set the estimation window
How many past months each optimisation sees, from 12 to 120. Sixty months is a common starting point.
- 4
Set rebalancing and costs
Monthly, quarterly or annual re-optimisation, and a cost in basis points on the value traded. Use a cost close to what you pay, including the bid-ask spread.
- 5
Compare promise with delivery
Read the in-sample Sharpe ratio, what the optimiser promised on its windows, against the out-of-sample one it delivered, and both against equal weight on the same dates.
- 6
Check weights and turnover
Look at how the weights moved and how much was traded each year. Large swings mean the method is reacting to noise.
- 7
Test robustness
Change the window, the frequency and the funds. Keep a method only if it holds up across reasonable settings, not because one setting looks best.
Pitfalls and common mistakes
Tuning the test. Running dozens of windows, frequencies and fund lists and reporting the best turns an out-of-sample test back into an in-sample one. Fix the settings before looking at results, and report the range across reasonable choices.
Short histories. ETF data here starts in the mid-2000s at best, and the first window uses up the first years, so the test covers one or two market cycles. Few regime changes mean wide uncertainty around any Sharpe ratio.
Selection of funds. Choosing funds because they did well, or because they exist today, builds hindsight into the test before the first optimisation runs. The hindsight optimum shows how much a perfect choice of weights was worth; a perfect choice of funds is hidden inside every line.
Ignoring costs and taxes. Monthly re-optimisation of a return-seeking objective can trade most of the portfolio every year. Set a realistic cost; taxes on realised gains are not modelled.
Unconstrained weights. Without caps, maximum Sharpe often puts most of the money in one or two funds. Jagannathan and Ma showed that even the no-short-sale limit acts like shrinking the most extreme estimates [5]; a maximum weight per fund does more. Test with the limits you would actually use.
Currencies. Returns are in each fund’s trading currency. Mixing US-dollar and euro funds mixes in currency moves, which the optimiser treats as part of each fund’s risk and return.
Rolling optimisation compared with related tests
| Approach | Data used for the weights | What it tells you | Weakness |
|---|---|---|---|
| Static optimisation (full period) | All months, including the ones it is judged on | The best fixed mix in hindsight | In-sample: overstates what was achievable |
| Single split (first half / second half) | The first half only | One out-of-sample period | Depends on where the split falls |
| Rolling (walk-forward), fixed window | The last W months at each date | A realistic track record with re-fitting and costs | Short histories; sensitive to W |
| Expanding window | All months up to each date | Same, with ever more data | Slow to adapt; early decisions rest on little data |
| Black-Litterman | Prior weights and your views | Weights consistent with stated views | Needs a sensible prior; views can embed hindsight |
| Equal weight (1/N) | None | The no-estimate baseline | Ignores differences in risk |
The single split is in the portfolio optimizer, the efficient frontier of two or three funds in the efficient frontier calculator, and views on expected returns in the Black-Litterman calculator. How software packages handle optimisation and its testing is compared in portfolio optimization software.
Rolling optimization: questions
What is rolling optimization?
A way to test a portfolio optimisation method as it would have been used in real time. At each rebalance date the weights are optimised on a trailing window of past data only, for example the last 60 months, then held until the next date, when the window moves forward and the optimisation is repeated. Chaining the months gives a track record in which every return was earned with weights chosen before it happened.
Is walk-forward optimization the same as rolling optimization?
In portfolio construction the terms are used for the same procedure: optimise on a window, apply the result to the period that follows, step forward, repeat. Walk-forward analysis comes from the testing of trading systems, where the parameters of a rule are re-fitted on each window. Some walk-forward tests use an expanding window that keeps all past data; this tool uses a rolling window of fixed length, so old data drops out.
Why is the out-of-sample Sharpe ratio lower than the in-sample one?
Because an optimiser fits the noise in its window as well as any real pattern, and the noise does not repeat. In-sample, the chosen weights look as good as they can on the data used to pick them; out of sample, only the persistent part remains. For SPY, EFA, AGG, TLT and GLD, maximum-Sharpe weights averaged a Sharpe ratio of 1.33 on their own 60-month windows and delivered 0.69 from Jun 2012 to Oct 2026. Methods that do not use average returns usually show a smaller gap.
What estimation window should I use?
There is no right answer, which is why the tool lets you change it. Short windows react to change but estimate average returns with a lot of noise; long windows are steadier but slow to adapt and need longer histories. On the default funds, maximum Sharpe with a 36-month window delivered an out-of-sample Sharpe ratio of 0.81 (Jun 2010 to Oct 2026) and with a 120-month window 0.69 (Jun 2017 to Oct 2026); the test periods differ, so compare each with its own equal-weight figure. A result that only works for one window length is fragile.
How often should a rolling optimisation rebalance?
More often means fresher estimates but more trading. Monthly re-optimisation of a return-seeking objective can turn over the whole portfolio several times a year, and costs and taxes grow with it; quarterly or annual rebalancing trades less and lets the weights drift in between. Run the same settings at each frequency with realistic costs and keep the one whose result does not depend on frequent trading.
Does optimisation beat equal weighting out of sample?
Often not. DeMiguel, Garlappi and Uppal (2009) tested 14 optimisation models on seven datasets with rolling estimation windows and found none consistently better than the 1/N portfolio on Sharpe ratio, certainty-equivalent return or turnover. On the default funds, walk-forward maximum Sharpe delivered 0.69 against 0.62 for equal weights rebalanced on the same dates. Your result depends on the funds and the period; run it on yours.
Which optimisation objective holds up best out of sample?
Objectives that use only volatilities and correlations, such as minimum volatility and risk parity, are usually more stable than maximum Sharpe, because risk is estimated far more precisely than average return. In the default test the highest out-of-sample Sharpe ratio of the four came from maximum Sharpe, with 0.69. Stability is not the same as the highest return: minimum volatility often has the lowest one.
What is the difference between in-sample and out-of-sample?
In-sample results are measured on the same data the method was fitted to, so they include everything the method learned by chance. Out-of-sample results are measured on data the method had not seen when it chose. Only the second tells you how the method might behave on data it has not yet seen, which is what investing requires.
How are turnover and transaction costs calculated?
At each rebalance the tool compares the new target weights with the weights the market left after drift. The sum of the absolute differences is the value bought and sold; the cost is that sum times the basis points you set, taken from the portfolio. Turnover is reported one-way, half that sum, averaged per year: 100% means replacing the whole portfolio once a year. The first purchase is free for every strategy.
What is the static optimum with hindsight?
The single fixed mix that the same objective picks when it can see every month of the test. It is the best you could have done with one set of weights chosen after the fact, so it is in-sample by construction. It shows how much of the gap between the walk-forward result and the hindsight result is the price of not knowing the future.
How does the tool avoid look-ahead bias?
A decision taken at the end of a month uses the window of months that ends with that month, and its weights earn the returns of the following months only. Months enter the data only once complete, and the hindsight optimum, which does look ahead, is labelled in-sample. Changing a future month’s returns cannot change any earlier decision.
Which funds can I test, and is it free?
Any 2 to 8 of the US and European ETFs covered by our ETF pages, on monthly total returns with dividends reinvested, with windows from 12 to 120 months. It is free, needs no account and runs in your browser; the link reproduces your settings, and the decisions and monthly returns download as CSV.
Related tools and guides
- Portfolio optimizerMax Sharpe, min volatility, risk parity
- Black-Litterman calculatorImplied returns blended with your views
- Efficient frontierEvery mix of 2–3 ETFs
- Portfolio optimization softwareWeb apps and Python libraries compared
- Portfolio backtestFixed weights, rebalancing rules, cash flows
- Tactical asset allocationMoving average and momentum rules
Sources
- Markowitz, H. (1952). Portfolio Selection. The Journal of Finance, 7(1), 77–91. doi.org/10.1111/j.1540-6261.1952.tb01525.x
- DeMiguel, V., Garlappi, L., & Uppal, R. (2009). Optimal Versus Naive Diversification: How Inefficient Is the 1/N Portfolio Strategy? The Review of Financial Studies, 22(5), 1915–1953. doi.org/10.1093/rfs/hhm075
- Michaud, R. O. (1989). The Markowitz Optimization Enigma: Is “Optimized” Optimal? Financial Analysts Journal, 45(1), 31–42. doi.org/10.2469/faj.v45.n1.31
- Chopra, V. K., & Ziemba, W. T. (1993). The Effect of Errors in Means, Variances, and Covariances on Optimal Portfolio Choice. The Journal of Portfolio Management, 19(2), 6–11.
- Jagannathan, R., & Ma, T. (2003). Risk Reduction in Large Portfolios: Why Imposing the Wrong Constraints Helps. The Journal of Finance, 58(4), 1651–1683.
- Maillard, S., Roncalli, T., & Teïletche, J. (2010). The Properties of Equally Weighted Risk Contribution Portfolios. The Journal of Portfolio Management, 36(4), 60–70.
- Bailey, D. H., Borwein, J. M., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471. doi.org/10.1090/noti1105
Source: MarketStack end-of-day prices, total return with dividends reinvested; MEDGE Capital calculations. Figures are historical and descriptive; they are not forecasts and not investment advice. MEDGE Capital does not recommend buying or selling any instrument. Risk disclaimer.