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_bargives 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.