Stock Backtesting: How to Test an Equity Strategy Properly

11 min readQuantParadox research

Equity backtests fail in ways forex backtests do not, and the differences are mostly about data rather than about strategy. Almost all of them push the result in the same flattering direction.

The short answer

Stock backtesting requires handling problems that spot forex does not have — a changing universe of listed companies, splits and dividends that alter historical prices, overnight gaps and short-selling constraints — and ignoring any of them inflates results substantially.

What makes stock backtesting harder than forex?

Stocks introduce four problems that spot currency pairs largely avoid: the universe changes over time, historical prices are rewritten by corporate actions, prices gap overnight, and shorting has costs and constraints that vary by name and by day.

The universe problem is the largest and the least visible. EUR/USD existed throughout your test window; a given ticker may have listed halfway through, been acquired, changed name, or delisted after failing. A backtest run over today's list of companies has quietly excluded every company that stopped existing.

Corporate actions rewrite the price series itself. A two-for-one split halves the price without any economic event occurring, and a backtest reading unadjusted data will see a fifty per cent crash. Dividends do the reverse at a smaller scale, and there are several defensible ways to adjust for them that produce different series.

Overnight gaps mean your stop is a suggestion. A stop at ninety-eight on a stock that opens at ninety fills at ninety, and a tester that assumes stops fill at their level is understating the worst outcomes exactly where they matter most.

How do you handle splits and dividends in a backtest?

Use a consistently adjusted price series, know which adjustment your data uses, and check that the adjustment factors are applied to the whole history rather than from an arbitrary start date.

Split adjustment is the less ambiguous of the two: multiply pre-split prices by the split ratio so the series is continuous. The pitfall is partial application. If a vendor applies adjustments only from a certain date, or if you cache data before a split and refresh after it, you end up with a series containing an artificial jump that no strategy should have to survive.

Dividend adjustment is genuinely ambiguous, because there are two reasonable conventions. Back-adjusting historical prices downward gives a series whose returns match total return; leaving prices unadjusted gives a series that matches what you would have seen on the screen. Both are defensible, and mixing them within one study is not.

The practical discipline is to verify rather than assume. Pick a stock with a known split, pull its history, and check that the price series is continuous across the split date. This takes five minutes and catches a class of error that otherwise shows up as an inexplicably profitable or catastrophic trade.

How should you model liquidity and position size in equities?

Cap the position at a small fraction of the stock's historical average traded volume, because a backtest with no size constraint will happily take positions no real order could have filled.

This is the equity-specific version of the cost problem, and it bites hardest exactly where backtests look best. Small-cap and micro-cap names produce the most spectacular historical returns and are the least able to absorb size. A strategy whose profits come from names trading a few hundred thousand dollars a day is describing an opportunity that may not exist at any meaningful capital.

A common convention is to limit each position to a small percentage of the average daily volume over some trailing window, and to treat any signal that would exceed it as partially filled or skipped. Which convention you use matters less than having one.

Also model the spread per name rather than as a constant. Equity spreads vary by orders of magnitude across the universe, and a flat one-cent assumption is generous for a liquid large-cap and wildly optimistic for anything thin.

What about short selling in a stock backtest?

Shorting is not the symmetric opposite of buying, and a backtest that treats it as such will overstate the returns of any strategy with a short leg.

Shares must be borrowable to be shorted, and availability varies by name and over time. The stocks a strategy most wants to short — heavily declining, high attention, small float — are precisely the ones most likely to be hard to borrow or unavailable entirely.

Borrow costs are real and can be substantial. For a hard-to-borrow name the annualised fee can exceed the return the strategy was hoping for, and it accrues daily whether or not the position moves.

There are also regulatory constraints that appear at inconvenient moments, including short-sale price tests triggered after sharp declines and outright temporary bans during market stress. A historical test that ignores these is assuming a trading environment that did not exist on exactly the days the strategy expected to make the most.

How much history do you need for a stock strategy?

You need enough history to include at least one serious market decline, because equity strategies that have only met rising markets have not been tested against the condition that decides whether they survive.

This is a stronger requirement than the equivalent in forex. Currency pairs range and trend in both directions continuously; equity indices have long periods where almost everything rises, and a strategy tested only across such a period has learned that buying works.

In practice that means a window spanning multiple market regimes, and being explicit about which ones. A backtest starting after a major bottom and ending at a high is describing a specific and unusually generous stretch of history.

It also means checking results per regime rather than only in aggregate. A strategy whose entire result comes from one bull run is a different proposition from one that contributed steadily throughout, and the headline metric cannot tell them apart.

Questions people actually ask

Can I use the same backtesting approach for stocks and forex?

The core discipline transfers — out-of-sample validation, realistic costs, counting trials, reporting sample size — but the data handling does not. Equities require a point-in-time universe, corporate action adjustment, per-name spreads and borrow constraints, none of which have a spot forex equivalent. A framework built only for FX will silently skip all of them.

Do I need tick data to backtest stocks?

It depends on the holding period. For strategies holding days or weeks, daily bars with correct corporate action adjustment are usually adequate, and the dominant error sources are universe construction and costs rather than intraday sequencing. For intraday equity strategies, the same-bar ambiguity problem applies exactly as it does in forex, and finer data is needed to resolve it.

How do I handle stocks that delisted?

Include them, with their actual outcome. A delisted company that went to zero has to remain in the historical universe at its real result, because removing it converts a loss into an absence and inflates every aggregate statistic. This requires a point-in-time universe from your data vendor rather than a current constituent list, and it is the single most consequential data decision in equity backtesting.

The only backtest that settles it is yours.

Build a strategy from a sentence, paste your own Python, or import your live trade history and have it graded. Five full backtests free, no card, and we'll tell you plainly when the result is indistinguishable from luck.

We publish research and tooling, not trading advice, and we make no claim about future returns. Everything above describes how to test an idea — not a reason to trade one.