FAQ · Getting systematic research right

What is backtesting in trading?

Backtesting runs a trading rule over historical prices as if it had traded at the time, and reports what it would have earned, lost and risked. A useful backtest lets the rule see only data that existed at each moment, fills its orders at prices that were actually available, and charges the costs a real account would have paid.

Backtesting runs a trading rule over historical prices as if it had traded at the time, and reports what it would have earned, lost and risked. A useful backtest lets the rule see only data that existed at each moment, fills its orders at prices that were actually available, and charges the costs a real account would have paid.

The four parts of a backtest

  • Historical data. Bars of open, high, low, close and volume, or ticks, for each instrument the rule trades, plus any other series it reads, such as earnings dates or an index level.
  • The rule. Code that looks at the data up to now and decides whether to buy, sell or do nothing. It might be a moving-average crossover, a mean-reversion signal or a model's forecast.
  • A simulated broker. It decides when and at what price each order fills: a market order at the next price, a limit order only if price reaches it, a stop when price trades through it. It charges spread, slippage and commission.
  • A report. Net profit, drawdown, win rate, Sharpe ratio and the list of trades. See how to read a backtest report.

What a backtest can tell you

  • Whether an idea made money in the past, after costs, and how much it risked to do so.
  • How the result depends on its parameters, costs and market conditions.
  • What to expect from a live account: how often it trades, how long trades last, how deep drawdowns go.

A backtest cannot prove a rule will work in the future. It can show that a rule did not work, or that it worked only under assumptions a live account will not meet, before real money finds out.

What makes a backtest trustworthy

Two ways to build one

  • Vectorised. Signals and returns are computed over whole arrays at once, for example in pandas. It is fast and good for a first look, but orders, stops and partial fills are hard to express, and it is easy to shift a column the wrong way and see the future.
  • Event-driven. The engine steps through time one bar at a time, calls the rule, and fills its orders on the following bars. It is closer to live trading, and the same rule can later run live.

How Reamer Research handles it

Reamer Research is an event-driven backtesting and live trading engine for Python and C++. Your rule is an on_bar that sees a window of closed bars and returns its orders; the engine fills them from the next bar under a public execution specification:

import reamer_research as rr

def on_bar(d):                                  # called once per closed bar
    if d.close[0] == 0:                         # window still filling
        return None
    fast, slow = d.close[-10:].mean(), d.close.mean()
    if d.position() == 0 and fast > slow:
        return rr.buy_market(10)                # fills from the next bar
    if d.position() > 0 and fast < slow:
        return rr.close_position()

result = rr.backtest(on_bar, 'data/SPY.bin', lookback=50,
                     spread=0.01, commission_per_unit=0.005)
print(result.net_pnl, result.sharpe_ratio, result.equity_drawdown_relative)

The same rule can be written as a class or as an object configured with its parameters. open_viewer=True opens the visual trade diagnostics tool on the finished run, with each trade on its candles beside the values the strategy printed.

Limits to know

  • Data is yours to bring. The kit reads CSV, .bin, Parquet and pandas, and includes fetchers for Alpaca and Databento bars.
  • Evaluation Mode runs 30 days or 50,000 bars of one ticker. Enough to learn the engine on your own data; longer and multi-ticker runs need a licence.

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

Next questions

How do I backtest a trading strategy step by step?Write the rule down precisely, get clean data for the instruments and period, set realistic costs, run it, then read both the report and the individual trades. Choose parameters on one part of the history, check them on another, and paper trade before risking money. Each step catches a different way a backtest can mislead.What is look-ahead bias and how do I find it in my backtest?Look-ahead bias is a backtest using information that was not available when the decision was made, such as filling at the close of the bar that produced the signal or reading data published later. Find it by checking when each value was known, shifting signals by one bar, and seeing whether results collapse.How do I read a backtest report? Sharpe, Sortino, drawdown and profit factor explainedStart with the trade count and costs, then risk-adjusted return (Sharpe and Sortino), then the worst loss from a peak (maximum drawdown), then how wins compare with losses (profit factor and win rate). No single metric is enough; a strategy is only as good as its weakest honest figure.How realistic do slippage and spread need to be in a backtest?Realistic enough that the result survives them. Set spread, slippage and commission per instrument from what your broker actually charges, let spread and slippage widen when the market moves fast, and then rerun at one and a half and two times those costs. A strategy whose edge disappears under slightly higher costs was never a reliable edge.

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.