---
title: "Portfolio backtesting: how to backtest a portfolio, step by step"
url: "https://amaltash.com/articles/portfolio-backtesting"
published: "2026-11-18T20:23:06.276701+00:00"
summary: "The short answer. Portfolio backtesting replays a mix of assets, with its weights, rebalancing rule, costs and cash flows, over past market data to see how it would have behaved. You compare it with…"
---

# Portfolio backtesting: how to backtest a portfolio, step by step

The short answer. Portfolio backtesting replays a mix of assets, with its weights, rebalancing rule, costs and cash flows, over past market data to see how it would have behaved. You compare it with…

Written by Charvi Agarwal (COO); Arpit Agarwal (Founder & CEO); Amaltash Research (Amaltash Advisors LLC).
Reviewed by Arpit Agarwal (Founder & CEO); Charvi Agarwal (COO); The Amaltash Team (Editorial review).
Updated 2026-11-18 · Published 2026-11-18.

The short answer. Portfolio backtesting replays a mix of assets, with its weights, rebalancing rule, costs and cash flows, over past market data to see how it would have behaved. You compare it with a benchmark using CAGR, max drawdown and the Sharpe ratio. The result is hypothetical, not a forecast.

Interactive calculator on the page: https://amaltash.com/articles/portfolio-backtesting

## Turn this into a rule

> Hold 60% SPY and 40% T-Bills. Rebalance back to 60/40 on the first trading day of each quarter, or sooner if either side drifts more than 5 points from its target.

[Turn this into a rule](https://invest.amaltash.com/strategy-builder?plan=Hold+60%25+SPY+and+40%25+T-Bills.+Rebalance+back+to+60%2F40+on+the+first+trading+day+of+each+quarter%2C+or+sooner+if+either+side+drifts+more+than+5+points+from+its+target.)

Opens the Strategy Builder with this rule filled in. It starts building after a 3-second countdown; type to stop it. Nothing trades until you deploy.

## What is portfolio backtesting?

Portfolio backtesting is testing a whole mix of investments on past market data. A mix is the set of things you own, each at a set share: for example, 60% in a stock fund and 40% in T-Bills, which are short-term loans to the US government. A regular backtest asks what one buying and selling rule would have done. A portfolio backtest asks what the whole mix would have done, rebalanced by a rule, with money added or withdrawn along the way.

The tool steps through history, one day or month at a time. At each step it moves each holding with its past price plus income, rebalances when the rule says so, adds deposits or takes out withdrawals, takes out costs and records the account value. Everything in the result comes from what you put in, so your inputs deserve most of your attention.

For the idea itself and the traps every test shares, such as overfitting and look-ahead bias, read [what backtesting is](https://amaltash.com/articles/backtesting) first. This page is the portfolio how-to.

## How do you backtest a portfolio? Step by step

Write each choice down before you run the test, so you cannot quietly change it after seeing the result.

1. Pick the holdings and target weights, for a reason you could have stated on the start date.
2. Get the data: total-return prices that include dividends and interest, in one currency. Note any years filled in with a stand-in index because a fund did not exist yet.
3. Set the rebalancing rule: on a calendar, when drift passes a band, or never. See [calendar vs threshold rebalancing](https://amaltash.com/articles/portfolio-rebalancing) for how the two differ. Trade at the next price after the rule fires, not the one that fired it.
4. Add cash flows: contributions or withdrawals, on the schedule you will really follow.
5. Charge costs: fund expense ratios, trading spreads and, in a taxable account, tax on rebalancing sales.
6. Choose a benchmark: a simple portfolio you could have held instead, with similar risk.
7. Measure the portfolio and the benchmark the same way: CAGR, max drawdown, recovery time, volatility and Sharpe ratio.
8. Repeat with other start dates, then run the pitfall checklist below.

## How to backtest a stock portfolio

Backtesting a stock portfolio works the same way, with a few more traps, because single stocks can close, merge or get dropped from an index.

1. Pick your stocks as of the start date. Don’t pick today’s winners and test them back in time.
2. Include stocks that later closed or were bought out, if your tool allows it.
3. Set a top limit for each stock, so one name can’t take over the mix.
4. Test across at least one big market drop.

## What metrics should a portfolio backtest report?

Report a few metrics, each defined the same way for the portfolio and its benchmark. No single number tells you enough on its own.

A benchmark is the plain alternative you could have bought, measured over the same dates with total return and the same costs. For a 60/40 stock and bond mix, a 60/40 index mix is a fair benchmark; 100% stocks is not.

You can check CAGR math with the [CAGR calculator](https://amaltash.com/cagr-calculator), and read how declines are measured in [max drawdown](https://amaltash.com/articles/max-drawdown).

Portfolio backtest metrics, defined

| Metric | What it measures | How it is calculated | Watch out for |
| --- | --- | --- | --- |
| CAGR (compound annual growth rate) | The steady yearly rate that turns the start value into the end value | (End value ÷ start value) to the power of (1 ÷ years), minus 1 | Hides the path: equal CAGRs can have very different falls |
| Max drawdown | The largest fall from a peak to a later low | (Low − prior peak) ÷ prior peak | One history’s worst; the next fall can be deeper |
| Recovery time | How long it took to get back to the old peak | Days from the low back to the prior peak | Withdrawals during a fall make it longer |
| Volatility | How much returns swing around their average | Standard deviation of returns, usually yearly | Counts gains and losses alike |
| Sharpe ratio | Return above cash per unit of volatility | (Average return − risk-free rate) ÷ standard deviation of that excess return | Changes with the period and the return frequency |

Source: Sharpe ratio as defined by William F. Sharpe, “The Sharpe Ratio,” Journal of Portfolio Management (Fall 1994). Other rows are standard formulas.

## The inputs that change the answer

Small input choices can change a portfolio backtest more than the choice of funds. Set each one on purpose, and write it down.

Fees are the input most often left out. In the SEC’s own example, $100,000 grows 4% a year for 20 years. With a 0.25% yearly fee it ends near $208,000; with a 1% fee, near $179,000. A test that skips fees skips that gap.

Portfolio backtest inputs and the trap in each

| Input | What you decide | Common trap |
| --- | --- | --- |
| Weights | The share for each holding | Picking weights after seeing what did well |
| Rebalancing | By the calendar, when shares drift, or never | Assuming rebalancing is free and instant |
| Dates | When the test starts and ends | One start date picked because it looks good |
| Price history | Real fund prices or a stand-in index | Stand-in data before a fund existed, not labeled |
| Dividends | Price plus income, or price only | Leaving out dividends and interest |
| Deposits and withdrawals | How much, and when | Testing one lump sum when you will withdraw every year |
| Costs and taxes | Fund fees, trading costs, taxes on rebalancing | Leaving them out |

## Pitfall checklist

Run through this list before you believe any portfolio backtest, yours or anyone else’s.

Start dates matter more than most people expect. A test that starts at the S&P 500’s Jan 3, 2022 record close opens with a 25.4% fall to Oct 12, 2022, and the index did not close back at that record until Jan 19, 2024. Those are price-index closes, without dividends.

1. Hindsight: would you have picked these holdings on the start date, or only now that you know how they did?
2. Start-date luck: does the picture hold if you move the start a year or two either way?
3. Too little history: does the test include at least one [stock market crash](https://amaltash.com/articles/stock-market-crash) and one long flat stretch?
4. Stand-in data: which years use an index because the fund didn’t exist yet?
5. Missing funds: were funds that closed or merged left off the list you chose from?
6. Missing income: are dividends and interest included?
7. Costs and taxes: are fund fees, trading costs and taxes on rebalancing counted?
8. Withdrawals: if you will take money out, does the test do that too, on a realistic schedule?
9. Things that move together: does the result depend on two holdings always moving in opposite ways?

## Sequence risk: why the order of returns matters

Say you never add or take out money. Then the order of good and bad years doesn’t change where you end up. Once you withdraw money, order matters.

Withdrawals during a drop sell things at low prices, which leaves less money to recover. The same yearly returns, in a different order, can leave you with a very different balance. This is called sequence risk.

A backtest only shows the one order history happened to deliver. Try the sequence-risk calculator on this page with your own numbers. It shows the math of your inputs; it does not predict anything.

## Correlations change

Many mixes assume one part goes up when another goes down. Those relationships have shifted over time. There have been stretches when stocks and bonds fell together, for example when inflation and interest rates rose quickly.

If a backtest looks calm mainly because two holdings balanced each other, ask what happens if they stop.

## Free portfolio backtesting: what a tool should do

Free portfolio backtesting tools are a fine place to start. Amaltash’s Strategy Builder lets you describe a mix and a rebalancing rule in plain English, read the rules it writes, test them on past US stock and ETF prices and paper trade before you go live. A backtest there is hypothetical too, and real results will be different.

Free or paid, a good portfolio backtesting tool should let you do these five things:

1. Set weights and a rebalancing rule, including drift bands.
2. Add deposits and withdrawals on a schedule.
3. Include dividends and fund fees.
4. Show the biggest drop and how long recovery took, not just an average.
5. Tell you which years use stand-in data.

## Using a portfolio backtest well

Use the test to understand the bad times. How deep was the biggest drop? How long did recovery take? Could you have stayed in through it?

Those answers help you size each holding and set limits more honestly than an average return does.

Under the SEC Marketing Rule, performance “derived from model portfolios” and backtested performance both count as hypothetical performance. That is why this page shows no portfolio results.

## Risks and limits

- Hindsight: weights or holdings picked after the fact make a backtest look better than any real choice could.
- Look-ahead bias: using data, fund lists or index members nobody had on the test date makes the result look better.
- Past results do not predict future results. Backtested portfolio results are hypothetical. No real account earned them.
- Holdings that balanced each other in the test can stop doing that when you need it most.
- Rules can be set up differently than you meant. Read the rules before you test or go live. You can lose money.

## Frequently asked questions

### How far back should a portfolio backtest go?

Long enough to include several kinds of markets, including at least one severe decline. Check whether early years use proxy data because a fund did not exist yet.

### What is the difference between price return and total return?

Price return counts only price changes. Total return also adds dividends and interest, as if they were reinvested. A portfolio backtest should use total return, or it understates holdings that pay income.

### What is an asset allocation backtest?

It is a portfolio backtest of a mix of asset classes, such as 60% stocks and 40% bonds, rather than of single trades. The same steps and traps apply.

### Should a portfolio backtest include taxes?

If the portfolio will sit in a taxable account, yes. Rebalancing sales can realize capital gains, and that tax is a real cost. Inside an IRA or 401(k), trades are generally not taxed when they happen.

### Why do portfolio backtests differ between tools?

Tools use different data, stand-in indexes, dividend handling, rebalancing timing and costs. Two honest tools can give different answers for the same portfolio.

### Can a portfolio backtest pick investments for me?

It is better for rejecting a portfolio whose bad stretches you could not live with than for picking a winner. Choosing assets because they tested well is a form of overfitting.

## Sources

- [SEC: Investment Adviser Marketing, final rule release IA-5653 (December 2020)](https://www.sec.gov/files/rules/final/2020/ia-5653.pdf)
- [SEC Investor.gov: How Fees and Expenses Affect Your Investment Portfolio (Investor Bulletin)](https://www.investor.gov/introduction-investing/general-resources/news-alerts/alerts-bulletins/investor-bulletins/updated)
- [Investor.gov: Beginners’ Guide to Asset Allocation, Diversification, and Rebalancing](https://www.investor.gov/additional-resources/general-resources/publications-research/info-sheets/beginners-guide-asset)
- [William F. Sharpe: The Sharpe Ratio, Journal of Portfolio Management (Fall 1994)](https://web.stanford.edu/~wfsharpe/art/sr/sr.htm)
- [Amaltash index drawdown dataset (CSV, CC-BY 4.0)](https://amaltash.com/data/index-drawdowns.csv)
- [Bailey, Borwein, López de Prado and Zhu: Pseudo-Mathematics and Financial Charlatanism, Notices of the AMS (May 2014)](https://www.ams.org/notices/201405/rnoti-p458.pdf)
- [Bailey, Borwein, López de Prado and Zhu: The Probability of Backtest Overfitting (SSRN)](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2326253)

## Keep reading

- [What is backtesting?](https://amaltash.com/articles/backtesting)
- [Rebalancing a portfolio: calendar vs threshold](https://amaltash.com/articles/portfolio-rebalancing)
- [Sequence-of-returns risk](https://amaltash.com/articles/sequence-of-returns-risk)
- [Max drawdown explained](https://amaltash.com/articles/max-drawdown)

---

Educational content published by Amaltash Advisors LLC. Nothing here is investment advice or a recommendation to buy or sell any security. All investing involves risk of loss, including loss of principal, and past performance does not guarantee future results.
