Historical Data for Backtesting
Backtests are only as good as their data. Learn data types and sources, quality checks, corporate action adjustments and how to avoid survivorship traps.
Every backtest depends on historical data, and flawed data produces flawed conclusions with complete confidence. Missing delisted stocks, unadjusted splits, wrong timestamps or a single bad price can turn a losing strategy into an apparent winner. Choosing the right data, understanding its limits and checking its quality are some of the least glamorous but most important steps in trading research.
Types of historical data#
| Type | Granularity | Typical use | Lesson |
|---|---|---|---|
| Daily bars (OHLCV) | One bar per day | Swing and position strategies | Tick Data and OHLCV Data |
| Intraday bars | 1 minute to 1 hour | Day trading strategies | Tick Data and OHLCV Data |
| Tick and trade data | Every trade | Execution research, scalping | Tick Data and OHLCV Data |
| Order book data | Every quote change | Market making, microstructure | Order Book Feeds: Snapshots and Incremental Updates |
| Fundamental data | Quarterly and annual | Value and quality strategies | Fundamental Data |
| Alternative data | Varies | Specialised signals | Alternative Data Explained |
| Corporate actions | Events | Adjusting prices correctly | Corporate Actions, Delistings and Rolls in Backtests |
Data sources#
| Source type | Examples | Notes |
|---|---|---|
| Free | Exchange websites, public APIs, some broker feeds | Often limited history, survivorship bias, errors |
| Broker and platform data | Data from trading platforms | Convenient; check adjustments and gaps |
| Commercial vendors | Providers of research grade equity, futures and options data | Costly; point in time and delisted data available |
| Exchange historical products | Official tick and order book archives | Highest detail; expensive and large |
| Crypto exchange APIs | Trade and order book history | Free but varies by exchange; venue differences |
Data quality checks#
| Check | What to look for |
|---|---|
| Missing periods | Gaps in dates or times |
| Outliers | Impossible jumps, prices outside the day's range. See Outliers and Robust Statistics |
| Zero or negative values | Bad records (except where negative prices really occurred) |
| Duplicate records | Repeated bars or trades |
| Timestamp consistency | Time zones, daylight saving, bar labelling (start vs end). See Timestamps, Time Zones and Daylight Saving |
| Corporate actions | Splits and dividends handled correctly. See Splits and Dividends in Price Data |
| Cross checks | Compare against a second source |
Point in time data#
Fundamental data and index memberships must reflect what was known on each date, not later revisions or today's lists. Point in time databases preserve the original values. See Point-in-Time and Survivorship-Free Data and Look-Ahead Bias.
Futures and options data#
- Futures: each contract expires, so long histories require continuous series built with roll rules and adjustments. See Continuous Futures and Back-Adjustment.
- Options: many strikes and expiries; bid and ask quotes matter more than last trades, which can be stale.
How much history?#
Enough to include different market regimes: bull and bear markets, high and low volatility, rising and falling rates. For daily strategies, 10 to 20 years or more is common; for intraday strategies, several years of high quality intraday data may suffice, but should still cover varied conditions. See Structural Breaks and Regime Changes.
Data storage and versioning#
Store raw data unchanged, apply cleaning in documented steps and version datasets so backtests can be reproduced. See Data Storage, Compression and Caching and Data Versioning, Lineage and Schemas.
Frequently asked questions#
What data do I need for backtesting?#
Price data at the right frequency, adjusted for corporate actions, plus any fundamental or alternative data your strategy uses, all free of survivorship and look ahead bias.
Is free data good enough for backtesting?#
Sometimes for simple daily strategies, but free data often has errors, gaps and survivorship bias, so it should be checked carefully.
What is survivorship bias in data?#
Using only securities that exist today, which excludes failures and makes historical performance look better than it was.
Next, learn how to test on data the strategy has never seen in In-Sample vs Out-of-Sample Testing.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- The Trading Research ProcessResearch and Backtesting
- Backtesting MethodologyResearch and Backtesting
- Quant Trading Learning PathStart Here
- Quantitative TradingStrategies and Styles
- Market Data ExplainedData and Alternative Data
- Backtesting Libraries ComparedProgramming and Data