· Acubic Research · 9 min read
How to Backtest a Portfolio Before You Invest
Key takeaways
- A backtest shows what a set of rules would have done in a specific historical period. It cannot show what those rules will do next.
- Write your investment or rebalancing rule before looking at the historical data. A rule written after inspecting the data is fitted to noise, not tested against it.
- Split your data into a development period and a separate out-of-sample period the rules never touch during construction.
- Read maximum drawdown alongside cumulative return. A portfolio that halved in one stretch may have returned more overall, but it is much harder to hold through the loss.
- Survivorship bias inflates most backtests: assets that failed, were delisted, or were acquired are absent from a universe built from today's listings.
Running a backtest sounds definitive: apply your rules to historical prices, observe how the portfolio would have performed, and decide whether the strategy is worth using. In practice, a backtest is a useful sanity check with specific, well-understood limits. It is not a result that transfers directly to the future, and knowing what those limits are is as important as knowing how to run the test. This article covers both: the steps for a backtest that produces useful information, and the errors that make many backtests misleading.
What a backtest tells you and what it does not
A backtest answers one question: given a fixed set of rules and historical prices, what would those rules have produced over that specific period? It cannot tell you what the rules will produce on data that does not exist yet, because the future is not in the historical record.
The distinction matters because a well-executed backtest can tell you several genuinely useful things: how deep the worst drawdowns would have been, how often the rebalancing trigger would have fired and what that trading activity would have cost, whether one holding or sector would have dominated the portfolio's risk at any point, and whether two candidate allocations behaved differently under the same historical conditions. These are checkable, honest questions that historical data can answer.
What a backtest cannot do is confirm that a rule will outperform in the future, particularly after costs. A rule that appears to earn strong returns in-sample may have captured a pattern specific to that period, or it may have been shaped by the data during construction. The article on why Acubic does not predict the market explains the structural difficulty of deriving reliable forward-looking claims from historical evidence, and the same logic applies to selecting a portfolio strategy from backtest results.
Use a backtest to compare candidate allocations, not to prove that one is correct. The right question is not "did this rule work?" but "which of these two rules behaved better under the same conditions, and what does that tell me about each rule's properties?"
Write the rule before you look at the data
The most common error in backtesting is running the data first and writing the rule second. If you examine historical returns, notice a pattern, and then write a rule to capture it, you are describing the past rather than testing a hypothesis. The rule is not a prediction; it is a report of one period.
The correct sequence is:
- State the investment or rebalancing rule completely before opening the historical data. Which assets are eligible? How are they selected and weighted? When does the portfolio rebalance? What triggers a rebalance: a calendar date, a drift threshold, or both? The rule must be complete enough that someone else could implement it without asking you any questions.
- Apply the rule to the historical data. Only at this point do you look at what it produces.
- If the result prompts you to revise the rule, you have now used the data once. Any further testing on the same dataset is no longer independent. Record the revision and, if possible, reserve a separate data period for the revised rule before drawing any conclusions.
This rule-first discipline is what separates a test from a description. A rule written before the data is a hypothesis about a pattern. A rule shaped by the data is an observation about one period, and there may be no particular reason why the pattern repeats in the next.
Choose a benchmark, use adjusted prices, and account for costs
Before running the backtest, pick a benchmark: the comparison that gives the result context. A portfolio that returned 8% per year over a period sounds strong until you learn that a broad market index returned 11% over the same period at lower volatility. Without a benchmark, the number has no interpretation.
Use total return data that includes dividends, not just price returns. A stock that paid a 3% dividend each year but had flat prices would appear to have done nothing in a price-only series. Over a ten-year period, omitting dividends understates total return materially for equity and bond portfolios alike. Most professional data sources provide adjusted prices that account for dividends, splits, and other corporate actions; verify that yours does before drawing any conclusions.
Include a realistic estimate of transaction costs. At a minimum, account for the bid-ask spread on each trade and any platform commission. For a portfolio that rebalances quarterly and holds twenty positions, the cost of one rebalancing round is modest in isolation, but compounded over years it accumulates, and a rule that looks profitable before costs may look marginal after them. Running the backtest both with and without costs tells you how sensitive the result is to execution quality and how much the strategy depends on trading cheaply.
The article on portfolio rebalancing strategy covers how frequency and threshold rules affect the total amount of trading a portfolio generates, which is the main driver of transaction cost for a rules-based allocation.
Divide your data: in-sample and out-of-sample
The most important structural decision in a backtest is how to divide the historical data. The in-sample period is the data you use to develop and calibrate the rule. The out-of-sample period is the data you reserve, keep completely separate, and test the final rule against only at the end.
The in-sample result tells you whether the rule found something in that period. The out-of-sample result tells you whether the rule has any tendency to generalise to data it never saw. If the in-sample result looks strong and the out-of-sample result is weak, the rule is likely fitted to the specific conditions of the development period rather than capturing a durable pattern.
A common split for equity-based backtests is to use the earlier portion of the available data for development and reserve the most recent years as the out-of-sample test. The out-of-sample period should be long enough to contain at least one full market cycle: a sustained rise and a meaningful drawdown. A test period of one year in a rising market tells you very little about how the rule behaves in adverse conditions.
Walk-forward testing is a more rigorous variant of this idea. Rather than splitting the data once, you develop the rule on a rolling window, step forward by one period, record the result on the unseen period, and repeat. This produces a sequence of out-of-sample results that is harder to overfit than a single split, because the rule is tested each time on data it has not seen. The backtesting methodology guide covers the walk-forward approach in more detail, including the period lengths and rolling-window choices that give a reliable result.
Read drawdown alongside return
Cumulative return is the easiest number to extract from a backtest and one of the easiest to misread. Two portfolios can produce the same cumulative return over ten years through completely different paths. One might have grown steadily. The other might have doubled, then lost half its value, then recovered and continued. Their cumulative returns may match, but almost no investor would have stayed in the second portfolio through the fifty percent loss.
Maximum drawdown is the largest peak-to-trough decline in the portfolio's value over the backtest period, measured from any high before the recovery to a new high. It tells you the worst experience the strategy would have asked the investor to sit through. A portfolio with a maximum drawdown of twenty percent has been through something an investor can model against their own situation: would you have held it through that loss, or sold at the bottom?
A portfolio with a forty or sixty percent maximum drawdown requires a level of conviction and financial durability that most investors have not tested against a live loss. Strategies with headline-level returns but extreme drawdowns are often abandoned before they recover, converting a theoretical outperformance into a realised loss. The article on portfolio drift explains how uncorrected drift pushes allocations toward higher concentration and more volatility over time, which is one structural contributor to drawdown risk.
Beyond maximum drawdown, check the recovery time: how many months it took the portfolio to return to its previous high after the largest drawdown. A strategy that recovered in three months is a meaningfully different risk profile from one that spent three years below its previous peak.
Two errors that invalidate many backtests
Two technical errors appear in portfolio backtests more often than any other, and each biases the results in the same direction: they make the past performance look better than it was.
Survivorship bias occurs when the data set contains only the assets that survived the period, not all the assets that were present at the start. A database built from today's list of listed companies is missing every company that went bankrupt, was delisted, or was acquired at a loss during the period. If a strategy selects stocks based on historical momentum or quality screens, and all the low-momentum or low-quality names that failed have been removed from the data, the screened universe looks better than it did in real time. The selection rule appears to avoid disasters that were present in the data when a live investor using the rule would have held to them.
Lookahead bias occurs when the backtest uses information that would not have been available at the time the decision was made. A common example is using a company's year-end financial results to make a decision that would have been taken mid-year, before those results were published. Another is filling an order at the closing price on the same day you decide to trade, rather than the next day's opening price, which is when the order would actually have executed. Eliminating lookahead bias requires checking, for every input to the rule, the exact date the information became publicly available and not using it before that date.
For investors building a simple rebalancing portfolio using instruments on a major exchange, both biases are easier to manage: you are not screening individual equities by fundamental ratios, and the rebalance happens on a fixed calendar date using prices that were public the previous close. The more complex the rule, the more important the audit of each input's availability date becomes.
Getting started
For investors building a portfolio from scratch, a backtest is most useful after the allocation decisions are made, not as the primary input to them. Fix the goal, time horizon, risk tolerance, asset allocation, and rebalancing rule first, then run a backtest to check whether the resulting portfolio would have produced tolerable drawdowns under historical conditions.
Acubic includes a backtesting tool that shows the method and assumptions behind the results. The backtesting methodology guide covers the steps in this article and the walk-forward approach in more depth. Acubic does not promise returns and cannot predict short-term market moves. A backtest in the tool is evidence about one historical period, applied to a proposed allocation, not a forecast of what that allocation will do next.
To build and backtest a portfolio, the starting point is the AI portfolio builder. You can set your goals and risk level, review the resulting allocation, and run the historical check before connecting any broker account. The construction method is published on the methodology page, including the five model limitations that apply to the historical evidence the backtest produces.
Want to put this into practice? Explore the Acubic guides or see how the AI portfolio builder turns constraints into a structured portfolio.