FAQ · Getting systematic research right

How do I see why each backtest trade won or lost?

Chart each trade on the bars it ran on, with its entry, exit, stop and target marked, beside the indicator values your strategy saw when it decided. Then sort the trades and read the worst losers and the best winners one by one. A summary such as win rate or Sharpe ratio says whether a strategy made money; only the individual trades say why.

Chart each trade on the bars it ran on, with its entry, exit, stop and target marked, beside the indicator values your strategy saw when it decided. Then sort the trades and read the worst losers and the best winners one by one. A summary such as win rate or Sharpe ratio says whether a strategy made money; only the individual trades say why.

What to look for in a trade

  • Did it enter where the rule says? If the chart shows an entry where the indicator had not crossed, the code is not doing what you think.
  • What was the indicator doing on the signal bar? A breakout signal one cent above the level, or an RSI of exactly 30.0, is the edge case where bugs and luck live.
  • How did it exit? Stopped out at the low of a spike, targeted at the high, or closed by the rule? A strategy whose winners all exit by rule and losers all by stop behaves differently from one where both hit brackets.
  • What did it fill at? An exit far beyond its stop is usually a gap. See gaps and overnight fills.
  • What happened after? A stop that fired at the low before the move it predicted points at a stop that is too tight.

Read the extremes first

  • The worst losers show the risk a summary hides: a gap, a missing stop, a position the rule doubled.
  • The best winners show whether profit came from the idea or from one lucky day. If removing the top three trades turns the result negative, the strategy rests on them.
  • A random handful shows the typical trade, the one you will mostly live with.

How Reamer Research handles it

Reamer Research includes a visual trade diagnostics tool built for this. open_viewer=True opens it in the browser when the run finishes. It shows:

  • each closed trade on its candles, with entry and exit markers, stop-loss and take-profit levels, and the resting orders around it;
  • every value your strategy printed as name=value on each bar, drawn as a series over the price or in its own pane;
  • the console lines for the bars in view, with the trade's signal, entry and exit bars tagged;
  • a sortable trade table filtered to winners or losers, the equity curve, and a Monte Carlo simulation of the run.

This class prints the two values its decision depends on, so each trade can be checked against them:

import reamer_research as rr

class Crossover:
    lookback = 30
    def on_bar(self, d):
        if d.close[0] == 0:
            return None
        fast, slow = d.close[-10:].mean(), d.close.mean()
        print(f'fast={fast:.3f} slow={slow:.3f}')           # becomes two series
        if d.position() == 0 and fast > slow:
            return rr.buy_market(10, stop_loss=d.low[-10:].min())
        if d.position() > 0 and fast < slow:
            return rr.close_position()

result = rr.backtest(Crossover, 'data/SPY_5min.bin', spread=0.01,
                     result_json='crossover.json', open_viewer=True)
worst = sorted(result.closed_trades, key=lambda t: t['net_pnl'])[:3]
for t in worst:
    print(t['open_timestamp'], t['side'], round(t['entry_price'], 2),
          round(t['exit_price'], 2), round(t['net_pnl'], 2))

In the tool, the losers filter and the j and k keys step through those trades, each with its fast and slow lines drawn over the candles. The page is one HTML file written next to crossover.json, so it can be kept with the run or sent to someone else. The same class could be a plain on_bar(data) function or an object configured with its averages; whatever it prints is charted the same way.

Limits to know

  • The exit reason is inferred from prices. An exit at the stop or target level is labelled as such; the result records the exit price and time.
  • Charts are a fixed window around each trade. Context bars before the entry and after the exit are adjustable; there is no free scroll through the whole history.
  • Evaluation Mode runs 30 days or 50,000 bars of one ticker. The tool works the same on it.

A $20 month includes the full kit, so you can read every trade of your own strategy and cancel if it does not fit.

Next questions

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 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.How do I know if my backtest is overfit?You cannot prove a backtest is not overfit, but you can test for the signs. An overfit result holds at one parameter set and collapses at its neighbours, fails on data it was not tuned on, rests on a handful of trades, or disappears once realistic costs are applied. Check each one, on a tool that gives the same answer every run.Why do AI-written backtests give misleading results?AI assistants write backtests that run but often trade on the signal bar, leave out costs, fit values on the whole history, or test today's survivors. The code looks right and the numbers look great. Check the fill timing, the costs and the data the same way you would check a person's code, or run the strategy on an engine that enforces the timing for you.

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.