Search This Blog
A practical journal on algorithmic trading, market analysis, and building automated systems. Written by an independent developer and active trader.
Featured
- Get link
- X
- Other Apps
Before a Backtest Earns Real Money, Four Questions About Its Data
A backtest result is the joint product of two things: the rule that was tested, and the file it was tested against. Post-mortems almost always interrogate the rule — the entry, the filter, the stop. The four questions below interrogate the other half, because each one describes a way for the data by itself to manufacture a result the rule never earned.
None of this argues that historical testing is pointless. It argues something narrower: a result cannot be graded until the sample it came from has been graded, and these four defects are both common and invisible at the equity-curve level. They do not show up as a jagged curve or an ugly drawdown. They show up as a clean curve that does not repeat.
Question one — was the universe assembled after the outcomes were known?
The most convenient way to define a test universe is to download a current membership list and run it backwards. That single step conditions the entire sample on having survived to the download date.
Index membership is not a fixed set. The S&P Dow Jones Indices methodology for the S&P U.S. Indices states that changes to index composition are made on an as-needed basis and that there is no scheduled reconstitution, with additions and deletions announced at least three business days in advance. The deletion triggers named in the Index Maintenance section are concrete: a company involved in a merger, acquisition or significant restructuring such that it no longer meets the eligibility criteria; a stock moved to the pink sheets or the bulletin board; and a company that substantially violates one or more of the eligibility criteria, deleted at the Index Committee's discretion. A company removed from a component index must wait a minimum of one year from its removal date before it can be screened again.
Every one of those triggers is an event with a return attached to it. Filter them out and the remaining distribution is not the one that was available to trade.
The error runs in two directions, and the second one gets less attention. Omission removes the names that left. Back-dating adds names that were not there yet: a company added to the index three years ago, tested across a ten-year window, is being traded for seven years in which it was not a constituent and would not have appeared on any screen built from the index.
What the bias does to the result is not automatic in sign. Removals for merger or acquisition frequently carry a takeover premium, so excluding them strips positive outcomes out. Removals for delisting or eligibility failure usually strip negative outcomes out. Which effect dominates depends on the window and the strategy, so the honest statement is that the direction is an empirical question for a given test, not a rule of thumb. What is not in question is that the sample is no longer a random draw from what was tradeable.
This is not only an index problem. Any screen built by querying a current database of listed tickers has the same shape, because delisted symbols are frequently absent or thinly populated in a vendor's default view. The check is identical: was the universe for a given historical date reconstructed as of that date, or inherited from today?
Question two — could the decision have been made with what existed at that moment?
A backtest row carries a date. That does not mean every field in the row existed on that date. Look-ahead is not usually a coding blunder; it is usually a field that was filled in later and stamped with an earlier timestamp.
Three variants account for most of it.
- Retroactively adjusted price series. Split and distribution adjustments are applied backwards through the whole history when the event occurs. A price read today for a date several years ago is not the price that printed then. A rule keyed to an absolute level — a round number, a fixed dollar stop — is being tested against levels that never traded. Rules expressed in returns or in multiples of a volatility estimate are far less exposed to this than rules expressed in price.
- Fundamentals stamped with the period end rather than the filing date. A quarterly figure becomes public when the report is filed, not when the quarter closes. Under the General Instructions to Form 10-Q, codified at 17 CFR 249.308a, the report is due 40 days after the end of the fiscal quarter for large accelerated and accelerated filers and 45 days for all other registrants, and no quarterly report is required for the fourth quarter of a fiscal year. A test that has the quarter-end figure available on the quarter-end date is holding a number roughly six weeks before it was published.
- Bar-boundary leakage. Using a session's closing print to decide a trade that is then filled at that same close. The gap is small in wall-clock terms and large in effect, because the decision variable and the fill price are the same observation.
All three leave the same signature: performance that is strong, stable, and concentrated in exactly the moments where the leaked information mattered most.
Question three — is the number in the file the number that was published?
The third question is the easiest to verify from primary sources and the hardest to fix after the fact. Macro series are not fixed values. They are estimates that get corrected, and the corrected value is what a database returns today.
The US Bureau of Labor Statistics is explicit about the mechanism. The Current Employment Statistics program surveys about 119,000 businesses and government agencies representing approximately 622,000 individual worksites, and it revises its initial monthly estimates twice, in the immediately succeeding two months, to incorporate additional sample receipts from respondents. Separately, there is an annual benchmark — described by BLS as a once-a-year re-anchoring of the sample-based employment estimates to full population counts available principally through Unemployment Insurance tax records, with the Quarterly Census of Employment and Wages supplying roughly 97 percent of the benchmark level.
The sizes are not rounding errors. Across calendar 2025, the mean absolute revision to total nonfarm payrolls was 31,000 from the first to the second estimate, 39,000 from the second to the third, and 58,000 from the first to the third. One month shows the range clearly. June 2025 was first published on 3 July 2025 at an increase of 147,000. One month later it stood at 14,000. One month after that it stood at negative 13,000 — a total revision of 160,000 jobs, and a change of sign.
The benchmark operates on the level rather than the monthly change and is larger still. The March 2025 benchmark revised the not-seasonally-adjusted total nonfarm employment estimate by negative 862,000, or negative 0.5 percent; compared with the sample-based seasonally adjusted published estimate for the same month, the revision was negative 898,000, or negative 0.6 percent. BLS notes that over the prior ten years the annual benchmark revision at the total nonfarm level averaged 0.2 percent in absolute terms, with a range of less than 0.05 percent to 0.4 percent. The March 2025 figure is larger in absolute terms than the top of that stated range.
The same structure appears elsewhere. The Census Bureau's advance monthly retail trade estimate is drawn from a subsample of roughly 4,800 firms taken from the larger Monthly Retail Trade Survey, and the Bureau states that imputation is not performed for most nonrespondents in the advance survey. The advance number and the number that survives the annual integration are different objects.
There is a purpose-built remedy, and it is public. ALFRED, operated by the Federal Reserve Bank of St. Louis, retrieves each economic data release — each vintage — that was available on a specific date in history, across more than 350,000 real-time series, with archives running from 2006. A macro-conditioned test that has not been run against vintage data has not been tested; it has been fitted to a set of corrections that were not available when the trades would have been placed.
Question four — how many independent observations are in the sample?
The first three questions concern whether the data is honest. The fourth concerns whether there is enough of it to support the claim being made, and it can be settled with arithmetic rather than opinion.
Treat a completed trade as one Bernoulli outcome and ask what range of true win rates is consistent with what was observed. The exact (Clopper–Pearson) binomial interval answers this without any distributional assumption about returns. The results are blunt.
- 30 trades, 17 wins (56.7 percent). The 95 percent interval runs from 37.4 percent to 74.5 percent — a span of 37.1 percentage points. That sample is consistent with a rule that loses two trades out of three and with a rule that wins three out of four.
- 100 trades, 55 wins (55.0 percent). The interval runs from 44.7 percent to 65.0 percent, a span of 20.2 points. It still contains 50 percent, so the sample does not separate the rule from a coin.
- 500 trades, 275 wins (55.0 percent). The interval runs from 50.5 percent to 59.4 percent, a span of 8.9 points. This is the first of the three where the lower bound clears breakeven, and it clears it by half a point.
Two thresholds are worth carrying around. Holding the observed rate near 55 percent, the smallest sample whose 95 percent lower bound exceeds 50 percent is 390 trades. The smallest sample whose interval is narrower than five percentage points end to end is 1,559 trades. At a signal rate of two trades a week, 500 trades is about 4.8 years of history and 1,559 is about 15 years.
Two caveats make the picture worse rather than better. First, win rate alone does not describe profitability — a 45 percent rule with a large average win can dominate a 60 percent rule with a small one — so the interval above bounds one input, not the outcome. Second, trades are not independent when they overlap in time or share an exposure. Twenty positions opened in the same sector on the same week are closer to one observation than to twenty, which means the effective sample is smaller than the trade count and the true intervals are wider than the ones computed here.
The practical consequence is a ranking rule rather than a threshold. A small-sample result is not disqualified; it simply carries an interval wide enough that it cannot separate hypotheses that would be sized very differently.
What Would Invalidate This
This frame is about grading evidence, and there are conditions under which it is the wrong tool.
- Structural rules with no fitted parameters. Where a rule follows from a mechanical constraint — a settlement convention, an exchange rule, a mandated auction time — the sample is doing less work, because the effect was not discovered by search. The four questions still apply to the measurement of the effect's size, but not to the question of whether it exists.
- Very short holding periods. A rule that generates thousands of observations a year reaches useful sample sizes quickly, so question four loosens. Questions one through three tighten instead, because at that horizon the price series itself, tick timestamps, and the fill assumptions dominate everything else.
- Instruments with no membership problem. Question one is close to irrelevant for a single continuously listed future or a major currency pair. Applying a survivorship checklist there is wasted work.
- Rules that never touch macro releases. Question three is inert for a test that reads only prices. The revision literature matters exactly to the extent that the rule conditions on a published statistic.
- A sample large enough that the interval is tight and the result is still poor. The point of the interval is symmetrical. A wide interval around a good number is a reason for caution; a narrow interval around a bad number is a finding, and no amount of additional data cleaning will change it.
There is also a limit that no checklist removes. Passing all four questions establishes that a result was not created by the sample. It does not establish that the relationship persists, and nothing computable from historical data can establish that.
Concrete Framework
A sequence that can be run against any existing backtest, in the order that kills bad results fastest.
- Write down the universe rule before looking at results. State, in one sentence, how the set of tradeable instruments was determined for each historical date. If the sentence contains the words "current" or "today", the test has a survivorship problem and the size of it is unknown until it is rebuilt.
- Count the removals. For an index-based universe, list the constituents that left during the window and the reason each left. If that list is empty for a multi-year window, the data source is not point-in-time.
- Audit every field for its availability date. For each column the rule reads, record the date the value became public — not the date it describes. Fundamentals get the filing date, subject to the 40-day and 45-day Form 10-Q deadlines. Macro series get the release date. Prices get flagged if the rule uses absolute levels rather than returns.
- Re-run any macro-conditioned rule on vintage data. Pull the series from ALFRED as of each decision date and re-run. Compare the two equity curves directly. If the revised-data version is materially better, the gap is the measure of the look-ahead, and the vintage version is the one that counts.
- Compute the interval, not the point estimate. Record wins and total trades, compute the exact binomial interval, and write the interval next to the win rate everywhere the result is reported. Treat the lower bound as the number to plan against.
- Discount the trade count for overlap. Group trades that were open simultaneously or that shared a sector or factor exposure. Count each group as one observation and recompute the interval on the reduced count. Use the wider of the two intervals.
- Record how many variants were tried. Log every parameter set and every universe definition tested before the reported one. A result selected from forty attempts needs a materially wider margin than a result from one, and that count is impossible to reconstruct later if it is not written down at the time.
- Set the sample-size gate before the next test, not after. Decide in advance what interval width is required for a result to change position sizing, and hold to it when a promising short sample appears.
Steps one through four decide whether the result is real. Steps five through eight decide how much weight it can carry. Neither half substitutes for the other, and the failure mode the sequence exists to catch is always the same: a defect in the sample that produced the result before the rule ever had a chance to.
- Get link
- X
- Other Apps
Popular Posts
Trading Value vs. Market Cap — What the Numbers Actually Tell You About Who's Driving the Market
- Get link
- X
- Other Apps
Which Settlement Date Does the Short Interest Number on Your Screen Describe
- Get link
- X
- Other Apps
Comments
Post a Comment