# 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.

Source: https://learn.tradelabsai.com/research/historical-data-for-backtesting/  
Track: Research and Backtesting · Level: Intermediate · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Historical Data for Backtesting", https://learn.tradelabsai.com/research/historical-data-for-backtesting/

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](https://learn.tradelabsai.com/programming/tick-data-and-ohlcv-data/) |
| Intraday bars | 1 minute to 1 hour | Day trading strategies | [Tick Data and OHLCV Data](https://learn.tradelabsai.com/programming/tick-data-and-ohlcv-data/) |
| Tick and trade data | Every trade | Execution research, scalping | [Tick Data and OHLCV Data](https://learn.tradelabsai.com/programming/tick-data-and-ohlcv-data/) |
| Order book data | Every quote change | Market making, microstructure | [Order Book Feeds: Snapshots and Incremental Updates](https://learn.tradelabsai.com/programming/order-book-feeds/) |
| Fundamental data | Quarterly and annual | Value and quality strategies | [Fundamental Data](https://learn.tradelabsai.com/alternative-data/fundamental-data/) |
| Alternative data | Varies | Specialised signals | [Alternative Data Explained](https://learn.tradelabsai.com/alternative-data/alternative-data-explained/) |
| Corporate actions | Events | Adjusting prices correctly | [Corporate Actions, Delistings and Rolls in Backtests](https://learn.tradelabsai.com/research/corporate-actions-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](https://learn.tradelabsai.com/math/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](https://learn.tradelabsai.com/programming/timestamps-and-time-zones/) |
| Corporate actions | Splits and dividends handled correctly. See [Splits and Dividends in Price Data](https://learn.tradelabsai.com/programming/adjusted-prices/) |
| Cross checks | Compare against a second source |

**Example: A survivorship trap**
A trader backtests a strategy that buys the 20 cheapest stocks in today's S&P 500 by P/E, using a list of current members applied to 20 years of history. The backtest shows 16% a year. But the universe excludes hundreds of companies that were in the index earlier and later dropped out, many after poor performance or bankruptcy. Rebuilding the test with historical index membership, including delisted stocks, cuts the return to 9%. The original data quietly selected winners. See [Survivorship and Selection Bias](https://learn.tradelabsai.com/research/survivorship-and-selection-bias/).

## 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](https://learn.tradelabsai.com/programming/point-in-time-data/) and [Look-Ahead Bias](https://learn.tradelabsai.com/research/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](https://learn.tradelabsai.com/futures/continuous-futures/).
- **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](https://learn.tradelabsai.com/math/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](https://learn.tradelabsai.com/programming/data-storage/) and [Data Versioning, Lineage and Schemas](https://learn.tradelabsai.com/programming/data-versioning/).

## 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](https://learn.tradelabsai.com/research/out-of-sample-testing/).

## Continue learning

- Next lesson: [In-Sample vs Out-of-Sample Testing](https://learn.tradelabsai.com/research/out-of-sample-testing/)
- Previous lesson: [Backtesting Methodology](https://learn.tradelabsai.com/research/backtesting-methodology/)
- Related: [Backtesting Methodology](https://learn.tradelabsai.com/research/backtesting-methodology/): A backtest simulates a strategy on historical data. Learn the steps, the key performance metrics, common biases and a checklist for backtests you can trust.
- Related: [Cleaning Market Data](https://learn.tradelabsai.com/programming/cleaning-market-data/): Raw market data contains bad ticks, gaps, duplicates and wrong timestamps. Learn how to detect and fix common data errors without distorting your backtests.
- Related: [Survivorship and Selection Bias](https://learn.tradelabsai.com/research/survivorship-and-selection-bias/): Survivorship bias ignores failures; selection bias picks unrepresentative samples. Learn how both inflate backtests, fund returns and advice, and how to fix them.
- Related: [Point-in-Time and Survivorship-Free Data](https://learn.tradelabsai.com/programming/point-in-time-data/): Point in time data records what was known on each date, including restated figures and index changes. Learn why it matters and how to build point in time datasets.
- Related: [Splits and Dividends in Price Data](https://learn.tradelabsai.com/programming/adjusted-prices/): Adjusted prices remove the jumps caused by splits and dividends so returns are correct. Learn how adjustment factors work, when to use raw prices and common traps.
- Related: [Continuous Futures and Back-Adjustment](https://learn.tradelabsai.com/futures/continuous-futures/): Continuous futures stitch expiring contracts into one long price series. Learn back adjustment, ratio adjustment, roll rules and why they matter for backtests.
