FAQ · Reamer Research and Reamer Server: what they are and who they fit

How do I port a Backtrader strategy to Reamer Research?

Move the logic from Backtrader's next() into an on_bar that returns its order, replace buy_bracket with buy_market and its stop_loss and take_profit, and pass commission and spread to rr.backtest instead of setting them on Cerebro's broker. The worked example below is the same SMA crossover with a bracket in both engines, run on the same bars. Reamer Research, a Python and C++ backtesting and live trading engine, keeps Backtrader's bar-by-bar shape, adds visual trade diagnostics and seeded intrabar fills, and sends the same orders live through its relay.

Move the logic from next() into an on_bar that returns its order, and move the costs from Cerebro's broker into rr.backtest. A Backtrader strategy already decides one bar at a time, so the decisions carry over as they are. What changes is where the indicators, orders and costs are written.

What maps to what

  • bt.Strategy subclass becomes a class with on_bar(self, data), an object with that method, or a plain on_bar function.
  • __init__ indicators become arrays: data.close[-10:].mean() is a 10-bar SMA. lookback sets how many past bars data holds.
  • self.data.close[0] is data.close[-1], the bar that just closed.
  • self.position is data.position(), the signed quantity.
  • buy_bracket(stopprice=..., limitprice=...) is rr.buy_market(qty, stop_loss=..., take_profit=...). The stop and target are part of the order, so there are no child orders to track or cancel.
  • self.close() is rr.close_position().
  • cerebro.broker.setcommission and slippage settings are commission_per_unit= and spread= on rr.backtest.
  • GenericCSVData column mapping is a CSV path, a pandas DataFrame or a NumPy bar array passed straight to rr.backtest.
  • Analyzers are fields on the result: net P&L, return, closed trades, win rate, profit factor, Sharpe, Sortino, maximum drawdown and fees print with print(result), and result.closed_trades lists every trade.

The Backtrader version

A 10 and 30 bar SMA crossover that enters with a 1% stop and a 2% target, and exits early on the cross back down.

import backtrader as bt

class SmaCross(bt.Strategy):
    def __init__(self):
        fast = bt.ind.SMA(period=10)
        slow = bt.ind.SMA(period=30)
        self.cross = bt.ind.CrossOver(fast, slow)
        self.bracket = []

    def notify_order(self, order):
        if not order.alive() and order in self.bracket:
            self.bracket.remove(order)

    def next(self):
        if not self.position and not self.bracket and self.cross > 0:
            price = self.data.close[0]
            self.bracket = self.buy_bracket(size=100, exectype=bt.Order.Market,
                                            stopprice=price * 0.99,
                                            limitprice=price * 1.02)
        elif self.position and self.cross < 0:
            for order in self.bracket:
                self.cancel(order)
            self.close()

cerebro = bt.Cerebro()
cerebro.adddata(bt.feeds.GenericCSVData(
    dataname='SAMPLE_5min.csv', dtformat='%Y-%m-%d', tmformat='%H:%M:%S',
    datetime=0, time=1, open=2, high=3, low=4, close=5, volume=6,
    openinterest=-1, timeframe=bt.TimeFrame.Minutes, compression=5))
cerebro.addstrategy(SmaCross)
cerebro.broker.setcash(100_000)
cerebro.broker.setcommission(commission=0.005, commtype=bt.CommInfoBase.COMM_FIXED)
cerebro.addanalyzer(bt.analyzers.TradeAnalyzer, _name='trades')
strat = cerebro.run()[0]
t = strat.analyzers.trades.get_analysis()
print('net', round(cerebro.broker.getvalue() - 100_000, 2), 'trades', t.total.closed)

The Reamer Research version

import reamer_research as rr

class SmaCross:
    lookback = 31

    def on_bar(self, data):
        close = data.close
        fast_now, slow_now = close[-10:].mean(), close[-30:].mean()
        fast_prev, slow_prev = close[-11:-1].mean(), close[-31:-1].mean()
        crossed_up = fast_prev <= slow_prev and fast_now > slow_now
        crossed_down = fast_prev >= slow_prev and fast_now < slow_now

        if data.position() == 0 and crossed_up:
            price = close[-1]
            return rr.buy_market(100, stop_loss=price * 0.99,
                                 take_profit=price * 1.02)
        if data.position() > 0 and crossed_down:
            return rr.close_position()

result = rr.backtest(SmaCross, 'SAMPLE_5min.csv', initial_capital=100_000,
                     commission_per_unit=0.005, spread=0.01, rng_seed=1)
print(result)

More strategies in the same shape, with stop and target brackets, limit entries, risk-based sizing and several tickers, and loaders for CSV, .bin, Parquet, Alpaca and Databento bars, are in the Reamer Research examples repository on GitHub under the MIT licence, in Python, with C++ versions of the core examples.

To port with an AI assistant, the Reamer Research MCP server lets Claude Code, Claude Desktop or Cursor write the on_bar version, backtest it on your bars and compare its closed trades with the original's.

Running both on the same bars

On the Reamer Research kit's synthetic SAMPLE_5min.csv, with Backtrader 1.9.78.123 and Reamer Research 4.11.3:

  • Backtrader: 37 closed trades, net −476.47.
  • Reamer Research: 39 closed trades, net −643.17, the same on every run.

Both engines fill a market order on the next bar, so the entries line up. The totals differ because the Reamer Research run pays a 0.01 spread on every fill, which this Backtrader setup does not charge, and because the two engines settle a bar that touches both the stop and the target differently. Backtrader decides that bar from its open, high, low and close. Reamer Research walks a seeded tick path inside the bar. Set spread=0 to compare the fill rules alone.

What you get after the port

  • Visual trade diagnostics. Every closed trade on its own bars beside every value your strategy printed, to check each entry and exit against the rules.
  • Repeatable results. The same data, settings and seed give the same result to the byte.
  • Monte Carlo. result.monte_carlo(simulations=10000, seed=0) resamples the per-trade returns into loss, ruin and maximum-drawdown percentiles.
  • Live and paper trading. The relay sends the orders on_bar returns to your broker through the open-source receiver.

The four-engine benchmark

What a Backtest Costs ran Backtrader, NautilusTrader, QuantConnect LEAN and Reamer Research on the same strategies and data, on one AMD EPYC 9575F with Reamer Research 4.6.0. On one backtest of 500,000 bars, a 20-bar breakout with no costs, Backtrader took 15.04 s. Reamer Research took 3.38 s from Python and 0.36 s from C++.

The benchmark repository on GitHub has a runner for each of the four engines, the dataset builders and the raw results. Its Reamer Research runners use the same Python package and C++ header as the code above, so you can rerun every engine on your own machine. The study's author builds and sells Reamer Research, which is why the runners are public.

Reamer Research runs on Linux, macOS, or Windows through WSL2, from Python or C++. The free download runs both examples above in Evaluation Mode, on one ticker over up to 30 days of bars. A licence costs $20 per seat per month, cancel any time.

Next questions

What should I use instead of Backtrader now that it is no longer updated?Backtrader's last release was in April 2023. Reamer Research from Reamer Labs keeps Backtrader's bar-by-bar shape in a maintained engine library, free to download and $20 a month to license, with costs modelled by default, written fill rules, a visual trade diagnostics tool that charts every closed trade beside the values your strategy printed, and live orders through its relay; in a published benchmark on 500,000 bars, Backtrader took 15.04 s and Reamer Research took 3.38 s from Python. Among free tools, backtesting.py is the simplest step for one instrument, bt suits portfolio rebalancing, vectorbt suits parameter sweeps, and NautilusTrader and LEAN cover ticks, more asset classes and live trading.Why is my Python backtest so slow?Usually because a Python loop does expensive work on every bar, and that cost is multiplied by every bar and every run. Reading a value through pandas inside the loop is often the largest part. In one test, reading a single column row by row took about 12 seconds per 500,000 bars with iterrows and about 0.06 seconds with a NumPy array. Profile first, move data out of pandas before the loop, precompute what you can, run sweeps in separate processes, and move the loop to compiled code only if that is still not enough.How do I port a NautilusTrader strategy to Reamer Research?Move the logic from on_bar in your Strategy subclass into an on_bar that returns its order, replace the order factory's bracket with buy_market and its stop_loss and take_profit, and pass costs to rr.backtest instead of configuring a venue, instrument and fee model. The worked example below is the same SMA crossover with a bracket in both engines, run on the same bars. Reamer Research, a Python and C++ backtesting and live trading engine, keeps the strategy to one method and one call, with visual trade diagnostics, seeded intrabar fills and live orders through its relay.How do I port a QuantConnect LEAN algorithm to Reamer Research?Move the logic from OnData into an on_bar that returns its order, replace the market order plus separate stop and limit orders and their OnOrderEvent cancel logic with one buy_market carrying stop_loss and take_profit, and pass cash and costs to rr.backtest instead of Initialize. The worked example below is the same SMA crossover with a bracket in LEAN and in Reamer Research, run on the same bars. Reamer Research, a Python and C++ backtesting and live trading engine, runs on your own machine on your own data, with visual trade diagnostics, seeded intrabar fills and live orders through its relay.What is Reamer Research?Reamer Research is a deterministic backtesting and live trading engine for Python and C++, with a visual trade diagnostics tool; its relay sends live orders to your broker. You install it with pip or include one C++ header, on your own machine. It is built on a stable C ABI, so any other language that can call C can wrap it, live trading included. It tests a strategy, diagnoses it trade by trade, sweeps it, reports it, and sends its orders live, to your broker through the open-source receiver over the published protocol. Every order fills tick by tick on a seeded tick path the engine generates inside each bar, from bar data alone. Its visual trade diagnostics tool charts every closed trade on its own bars beside every value your strategy printed. The same data, settings and seed give byte-identical results every run. It costs $20 per seat per month, cancel any time.

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

Buy a licenceKey and kit by email on payment.