FAQ · Getting systematic research right

How much historical data do I need for a backtest?

Enough for the strategy to make at least a few hundred trades and to live through more than one kind of market, such as a crash, a long rise and a sideways stretch. For a daily strategy that usually means ten years or more; an intraday strategy reaches the same trade count in far less time but still needs several market regimes. Count trades, not years.

Enough for the strategy to make at least a few hundred trades and to live through more than one kind of market, such as a crash, a long rise and a sideways stretch. For a daily strategy that usually means ten years or more; an intraday strategy reaches the same trade count in far less time but still needs several market regimes. Count trades, not years.

Why the trade count matters

A backtest's average profit per trade is an estimate. Its uncertainty shrinks with the square root of the number of trades:

  • standard error ≈ standard deviation of trade returns / √n
  • t-statistic ≈ mean trade return / standard error

With 30 trades, a strategy whose average trade is a fifth of its trade-to-trade spread has a t-statistic around 1.1: indistinguishable from luck. With 300 trades the same edge gives about 3.5. If you tried many variants, the bar is higher still, because the best of many tries looks good by chance. See is my backtest overfit?

Why the market regime matters

A trend-following rule tested only on 2010–2019 has seen one long rise. A mean-reversion rule tested only on calm years has never met a crash. Periods worth covering for US equities include:

  • 2008–2009: a deep, long bear market.
  • 2020: a crash and recovery within months.
  • 2022: rising rates and falling stocks and bonds together.
  • Long quiet stretches, such as 2017, when volatility stayed very low.

If your data does not cover a kind of market the strategy may face, the backtest says nothing about it.

How to split it

Keep the most recent part as an untouched check, and use the rest to build. With ten years of daily data, a common split is seven to build and three to check, or a walk-forward test that rolls the split forward. See in-sample and out-of-sample splits.

When older data hurts

Markets change: decimalisation in 2001, the rise of electronic market making, new trading hours, new instruments. Very old data can describe a market that no longer exists. Test whether the result holds in the recent half as well as the full period.

How Reamer Research handles it

Reamer Research reports the trade count and every trade's profit, so the t-statistic is a few lines after the run:

import numpy as np
import reamer_research as rr

class Breakout:
    lookback = 21
    def on_bar(self, d):
        if d.close[0] == 0:
            return None
        if d.position() == 0 and d.close[-1] > d.high[:-1].max():
            return rr.buy_market(10, stop_loss=d.low[:-1].min())
        if d.position() > 0 and d.close[-1] < d.close[-10:].mean():
            return rr.close_position()

result = rr.backtest(Breakout, 'data/SPY.bin', spread=0.01, commission_per_unit=0.005)
pnl = np.array([t['net_pnl'] for t in result.closed_trades])
t_stat = pnl.mean() / (pnl.std(ddof=1) / np.sqrt(len(pnl)))
print(f'{len(pnl)} trades, mean {pnl.mean():.2f}, t = {t_stat:.2f}')

The same rule runs as an on_bar(data) function or an object configured with its lookback. Long histories are not a memory problem: .bin files are memory-mapped, so data larger than RAM runs. See backtesting data larger than RAM.

Limits to know

  • History is yours to bring. The kit includes fetchers for Alpaca and Databento bars; how far back you can go depends on your vendor.
  • Evaluation Mode runs 30 days or 50,000 bars of one ticker. That is enough to check the code, and rarely enough trades to judge an edge; full histories need a licence.

A $20 month includes the full kit, so you can run your strategy over all the history you have and cancel if it does not fit.

Every answer here restates the documents that ship in the kit, which are authoritative. All questions.

Reamer Research

Your first backtest in a minute

Backtesting and live trading in Python and C++. Free to install in Evaluation Mode, with no key or sign-up.

pip install reamer-research

A licence at $20 a month removes every limit. The same code runs unchanged.

Reamer Server

The order-management core for your firm

Your venues, your risk rules on every order, one strategy per CPU core, on your own Linux servers.

$24,000 / year

Or start with a 30-day trial at $2,000.