FAQ · Getting systematic research right

Should I backtest on adjusted or unadjusted prices?

Use split- and dividend-adjusted prices for stock backtests, so a 2-for-1 split does not look like a 50% crash and returns include the dividends a holder received. Keep the unadjusted prices beside them for any rule that depends on the actual price level, such as a minimum share price or a per-share commission.

Use split- and dividend-adjusted prices for stock backtests, so a 2-for-1 split does not look like a 50% crash and returns include the dividends a holder received. Keep the unadjusted prices beside them for any rule that depends on the actual price level, such as a minimum share price or a per-share commission.

What adjustment does

  • Split adjustment. After a 2-for-1 split, the share price halves while the holder's value does not change. Every price before the split is divided by 2 (and volume multiplied by 2), so the series is continuous.
  • Dividend adjustment. On the ex-dividend date the price drops by about the dividend, which the holder receives in cash. Every price before it is multiplied by 1 − dividend / previous close, so the series' return includes the dividend. This is often called a total-return series.

Split-only adjustment keeps prices closer to where they traded but leaves dividend drops in the returns; full adjustment gives correct returns but prices far back in time that never traded.

What goes wrong with each

DataBreaks
UnadjustedSplits look like crashes or spikes: stops trigger, signals fire, returns are wrong. Dividends are missing from returns.
Split-adjusted onlyEach ex-dividend drop looks like a loss; a high-yield stock's return is understated.
Fully adjustedEarly prices are lower than they traded, so price-level filters, per-share commissions and round-number levels are off.

A practical split

  • Signals and returns: fully adjusted closes.
  • Price filters and per-share costs: unadjusted prices, or the adjusted price times the cumulative adjustment factor.
  • Futures: a different problem, rolls between contracts. See futures rolls and FX swap.

How Reamer Research handles it

Reamer Research fills orders on the bars you give it, so the bars should be adjusted before the run. The kit's Alpaca fetcher asks for fully adjusted stock bars by default (adjustment='all', or 'split' or 'dividend'). Databento's equity bars are unadjusted, and its fetcher says so. For your own data, adjustment is a few lines of pandas:

import pandas as pd
import reamer_research as rr

def adjust(bars, splits, dividends):
    """bars: DataFrame indexed by date; splits: {date: ratio}; dividends: {date: cash}."""
    factor = pd.Series(1.0, index=bars.index)
    for day, ratio in splits.items():            # 2.0 for a 2-for-1 split
        factor[bars.index < day] /= ratio
    for day, cash in dividends.items():
        prev_close = bars['close'][bars.index < day].iloc[-1]
        factor[bars.index < day] *= 1 - cash / prev_close
    out = bars.copy()
    for col in ('open', 'high', 'low', 'close'):
        out[col] = bars[col] * factor
    out['volume'] = bars['volume'] / factor.where(factor > 0, 1)
    return out

raw = pd.read_csv('AAPL_raw.csv', index_col='date', parse_dates=True)
adj = adjust(raw, splits={pd.Timestamp('2020-08-31'): 4.0},
             dividends={pd.Timestamp('2020-08-07'): 0.82})
result = rr.backtest(my_strategy, {'AAPL': adj.reset_index()})

rr.backtest takes a pandas DataFrame directly. The volume line above scales volume by the whole factor, dividends included; scale it by the split ratios alone if you use volume in the rule. Keeping the unadjusted frame lets a strategy compare the two, for example as exogenous data attached to the ticker.

Limits to know

  • Corporate actions are yours to supply. The engine does not hold a split or dividend calendar; your vendor's adjusted bars, or a list like the one above, provide it.
  • Evaluation Mode runs 30 days or 50,000 bars of one ticker. Enough to check the adjustment around one event; longer histories need a licence.

A $20 month includes the full kit, so you can backtest on your own adjusted data and cancel if it does not fit.

Next questions

What is survivorship bias and how do I avoid it?Survivorship bias is testing only on assets that still exist today, which leaves out the companies that were delisted, went bankrupt or were acquired. Avoid it by testing on the universe as it was on each date, with delisted names and their final prices included, from a data source that keeps them.Where does the market data come from?From whichever vendor you choose, in one call. Reamer Research's bundled fetchers pull historical bars from your own Alpaca or Databento account straight into a backtest, and bars of any type from any other source go in as arrays or as memory-mapped files built from CSV. You pick the vendor, pay it directly and switch whenever you like, and the engine stays lean because it carries no data feed of its own. Reamer Server takes orders from your strategies, which price from your own feed.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.Can I backtest futures with roll handling, or FX with swap costs?Yes, but only if the backtest handles two things a plain price series hides. In a continuous futures series, the price jump at each contract roll must not be counted as profit or loss. An FX position held overnight must be charged or credited swap every night it is held. A backtest that skips either can report a result the account would never have produced.

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.