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

How do I port a Pine Script strategy to Python?

Rewrite each ta. indicator as an array calculation on the bars, turn strategy.entry and strategy.exit into one order with its stop and target, and move the settings in strategy() into the backtest call. The worked example below is a Pine Script v6 SMA crossover with a bracket, and the same strategy in Reamer Research, a Python and C++ backtesting and live trading engine that runs on your own machine and data, with visual trade diagnostics and seeded intrabar fills.

Rewrite each ta. indicator as an array calculation on the bars, turn strategy.entry and strategy.exit into one order with its stop and target, and move the settings in strategy() into the backtest call. Pine Script already decides once per bar, so the logic carries over line by line. What changes is where the bars come from and how orders are written.

What maps to what

  • strategy(...) settings (initial_capital, commission_value, slippage) become initial_capital=, commission_per_unit= and spread= or slippage= on rr.backtest.
  • close, close[1] are data.close[-1] and data.close[-2]. lookback sets how many past bars data holds.
  • ta.sma(close, 10) is data.close[-10:].mean(). Other indicators are NumPy or pandas on the same arrays, or a library such as TA-Lib.
  • ta.crossover(fast, slow) compares this bar's values with the previous bar's, as in the example below.
  • strategy.position_size is data.position(), the signed quantity.
  • strategy.entry with strategy.exit(stop=, limit=) is rr.buy_market(qty, stop_loss=..., take_profit=...). A limit= or stop= on the entry itself is rr.buy_limit or rr.buy_stop.
  • strategy.close is rr.close_position().
  • request.security on another symbol is a second ticker in the dict passed to rr.backtest, read as data['QQQ'].close.
  • plot() and label.new() become print() calls in on_bar; the visual trade diagnostics tool shows each printed value beside the trade it belongs to.
  • The Strategy Tester's figures are fields on the result: net P&L, closed trades, win rate, profit factor, Sharpe, Sortino and maximum drawdown print with print(result), and result.closed_trades lists every trade.

The Pine Script 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:

//@version=6
strategy("SMA cross with bracket", overlay = true, initial_capital = 100000,
     commission_type = strategy.commission.cash_per_contract, commission_value = 0.005)

fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
crossedUp = ta.crossover(fast, slow)
crossedDown = ta.crossunder(fast, slow)

if crossedUp and strategy.position_size == 0
    strategy.entry("Long", strategy.long, qty = 100)
    strategy.exit("Bracket", "Long", stop = close * 0.99, limit = close * 1.02)
if crossedDown and strategy.position_size > 0
    strategy.close("Long")

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, 'bars.csv', initial_capital=100_000,
                     commission_per_unit=0.005, spread=0.01, rng_seed=1)
print(result)

bars.csv is your own bars, from your data vendor or broker, with date, open, high, low, close and volume columns. The class could equally be a plain on_bar(data) function, or an object configured with its two lengths. Loaders for CSV, .bin, Parquet, pandas, Alpaca and Databento bars are in the Reamer Research examples repository under the MIT licence.

Where the two results can differ

  • Fill timing. By default TradingView fills a market order at the next bar's open, and Reamer Research fills it on the next bar too, so entries line up. With process_orders_on_close = true, Pine fills on the signal bar's close; to match, compare against that setting's off state.
  • A bar that touches the stop and the target. TradingView's broker emulator assumes price went open, high, low, close when the open is nearer the high, and open, low, high, close otherwise, unless the bar magnifier is on. Reamer Research walks a seeded tick path inside the bar, the same on every run with the same seed.
  • The bars themselves. Your vendor's bars and TradingView's feed can differ in session times, adjustments and the odd print, which moves crossovers by a bar.
  • Costs. The Pine version above charges no spread; the Python version charges 0.01 on every fill. Set spread=0 to compare the fill rules alone.

So expect the same trades with small differences in fill prices, and the odd trade that differs on a bar where both exits were in range.

What you get after the port

  • Your own data and machine. Any bars you can load, on any number of tickers, without a chart in the loop.
  • Visual trade diagnostics. Every closed trade on its own bars beside every value your strategy printed.
  • Repeatable results. The same data, settings and seed give the same result to the byte.
  • Monte Carlo and parameter sweeps in Python. result.monte_carlo(simulations=10000, seed=0), or a loop over settings, in the same script.
  • Live and paper trading. The relay sends the orders on_bar returns to your broker through the open-source receiver.

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

Reamer Research runs on Linux, macOS, or Windows through WSL2, from Python or C++. The free package, pip install reamer-research, runs the example 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

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.How should a backtest fill a stop and a target that both fall inside one bar?Reamer Research settles it on a seeded tick path it generates inside the bar: whichever level the path touches first is the exit, the same way on every run. The bar alone cannot say which was hit first, so a backtest should settle it by one stated rule, apply that rule the same way on every run, and let you check how much the result depends on it. A strategy whose result changes when the rule changes depends on something the data does not contain.What is the best Python backtesting library in 2026? Backtrader, NautilusTrader, LEAN, QuantRocket and Reamer Research comparedThe best Python backtesting library in 2026 depends on what the result is for. Reamer Research from Reamer Labs, free to download and $20 a month to license, is a Python and C++ backtesting and live trading engine for strategies on bars of any type, with modelled costs, written fill rules, byte-identical runs, 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 of release 4.6.0 it ran 500,000 bars in 3.38 s from Python, against 13.61 to 76.85 s for NautilusTrader and 15.04 s for Backtrader. NautilusTrader suits ticks and order books, LEAN suits many asset classes, QuantRocket suits an all-in-one platform in Docker, backtesting.py suits one instrument, bt suits portfolio rebalancing, and vectorbt suits large parameter sweeps. Backtrader still has the most tutorials but has not been released since April 2023.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.How much do Reamer Research and Reamer Server cost?Reamer Research is USD 20 per seat per month, billed monthly, and you can cancel any time. Reamer Server is USD 24,000 per seat per year, paid once with no automatic renewal, with a 30-day trial at USD 2,000. A seat is one product on one machine.

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.