FAQ · Getting systematic research right

How do I size positions in a backtest?

Choose a sizing rule and compute the quantity at each entry. Fixed fractional risks a set share of equity per trade, volatility targeting scales size so each position carries similar risk, and ATR sizing sets quantity so a stop placed a multiple of ATR away loses a fixed amount. Then check the size against your buying power.

Choose a sizing rule and compute the quantity at each entry. Fixed fractional risks a set share of equity per trade, volatility targeting scales size so each position carries similar risk, and ATR sizing sets quantity so a stop placed a multiple of ATR away loses a fixed amount. Then check the size against your buying power.

Why sizing changes the result

The same entries and exits can produce a steady equity curve or a ruined account depending on size alone. A fixed quantity of shares means a trade at $20 and a trade at $200 carry very different risk. Sizing turns signals into risk you have chosen.

Common methods

  • Fixed quantity. Always trade the same number of shares or contracts. Simple, and fine for testing whether a signal works at all, but risk drifts with price.
  • Fixed notional. Spend the same amount per trade: qty = 5_000 / price. Risk still varies with how volatile each market is.
  • Fixed fractional. Risk a set share of current equity per trade, often 0.5% to 2%: qty = equity * 0.01 / (entry - stop). Size grows as the account grows and shrinks after losses.
  • ATR sizing. Place the stop a multiple of the Average True Range away and size so that stop loses a fixed amount: qty = risk_amount / (atr * 2). Each trade carries similar risk whatever the market's volatility.
  • Volatility targeting. Scale the position so its expected volatility matches a target: qty = (equity * target_vol) / (price * realised_vol). Common for portfolios and trend-following.
  • Kelly fraction. Size from estimated edge and odds. Full Kelly is very aggressive and sensitive to estimation error; practitioners who use it usually take a quarter or half.

Things to check

  • Buying power. The computed size may exceed what the account can carry at its leverage. A backtest that lets it through is testing an account you do not have.
  • Rounding. Shares and contracts come in whole units for many markets. Rounding down at small account sizes can mean a size of zero.
  • Compounding versus fixed risk. Compounding from equity makes results depend on trade order; a Monte Carlo resample shows how much.
  • Prop firm limits. Daily loss and trailing drawdown rules cap size in a way equity-based formulas do not. See backtesting prop firm rules.

How Reamer Research handles it

In Reamer Research every order carries the quantity your strategy computes, so any sizing rule is a few lines in on_bar. The kit's examples/risk_sized_strategy.py sizes each trade so its ATR stop costs a fixed amount, with a 2R target as a bracket:

import reamer_research as rr

class AtrSized:
    lookback = 15
    def __init__(self, risk=200.0, mult=1.5, max_notional=9_500.0):
        self.risk, self.mult, self.max_notional = risk, mult, max_notional
    def on_bar(self, d):
        if d.close[0] == 0 or d.position() != 0:
            return None
        tr = [max(d.high[i] - d.low[i], abs(d.high[i] - d.close[i-1]), abs(d.low[i] - d.close[i-1]))
              for i in range(-14, 0)]
        atr = sum(tr) / len(tr)
        entry, stop = d.close[-1], d.close[-1] - self.mult * atr
        qty = int(min(self.risk / (entry - stop), self.max_notional / entry))   # cap at buying power
        if qty > 0:
            return rr.buy_market(qty, stop_loss=stop, take_profit=entry + 2 * (entry - stop))

The same rule runs as a function on_bar(data) or a configured object as well. The margin model rejects an order whose notional, added to open positions, exceeds equity times leverage; the reason appears in data.action_results() on the next bar and in the order log. data.position_state() gives the open quantity, average entry, bracket levels and unrealised profit. Every run is byte-identical, so comparing two sizing rules on the same entries shows only the effect of size.

Limits to know

  • Equity-based sizing keeps its own running figure. on_bar gives each position's state and unrealised profit, not account equity, so a fixed-fractional strategy tracks equity from its own closed trades.
  • No native Windows build. It runs on Linux x86-64, on macOS on Apple Silicon, and on Windows through WSL2.

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

Next questions

How do I run a Monte Carlo simulation on backtest results?Take the per-trade returns from your backtest, draw them at random with replacement to build thousands of alternative trade sequences, and compound each one from your starting capital. The spread of final equity and maximum drawdown across those sequences shows how much of your single result was the order the trades happened to come in.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 strategy against prop firm rules like the daily loss limit and trailing drawdown?Run the backtest with the firm's account size and your real costs, then replay the closed trades day by day through the firm's rules: daily loss limit, maximum or trailing drawdown, profit target and minimum trading days. Reamer Research, a Python and C++ backtesting and live trading engine, gives you every closed trade with its time and net P&L, fills stops on a seeded tick path inside each bar, and repeats each run to the byte, so a pass or fail is the same every time you check it.How do I backtest a portfolio of several tickers?Run every ticker in one backtest against one shared account, so positions compete for the same capital and margin. Process bars in time order across all tickers, act on each ticker only when it has a fresh bar, and size each position against total equity. Testing tickers one at a time and adding the results misses the shared capital constraint.

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.