Quant Memo
Core

Backtest Result Caching and Invalidation

Caching backtest results speeds up research by reusing prior computations, but stale caches silently returning outdated numbers after a data or code change is one of the most common sources of untrustworthy research.

Backtests are expensive to rerun, so research systems often cache results — save the output of a backtest keyed by its inputs (strategy code, parameters, data version), and reuse that saved output instead of recomputing it the next time the same inputs appear. This saves enormous compute time when a researcher reruns a familiar configuration, or when many team members share overlapping work.

The danger is invalidation: knowing when a cached result is no longer valid and must be recomputed. If the underlying price data gets a corporate-action correction, or a bug in the backtest engine gets fixed, or a feature's calculation changes, any cached result that depended on the old version is now silently wrong — but if the cache key doesn't capture that dependency, the system will happily keep serving the stale, outdated number as if it were current. This is worse than no caching at all, because it looks correct.

A practical fix is making the cache key include a hash of everything the result actually depends on — not just the strategy parameters, but a version identifier for the data snapshot and the backtest engine's code itself — so that any change to data or code automatically produces a different key, forcing a fresh computation rather than silently returning a stale answer.

A cache is only as trustworthy as its invalidation rule — the key must capture every dependency (data version, code version, parameters) that could change the result, or the system will silently keep serving outdated numbers after an upstream fix, undermining the whole point of caching.

Related concepts

ShareTwitterLinkedIn