Position sizing for trading bots: fixed-fractional, ATR & Kelly
Most people obsess over entries. But the question of how much to trade — your position size — does more to decide whether your bot survives than any signal ever will. Two bots running the exact same strategy can have wildly different outcomes purely because one sizes sanely and the other doesn't. This guide covers the methods automated systems actually use, the one formula worth memorising, and why the textbook-optimal answer is almost never the one practitioners run.
Why sizing matters more than entries
An entry rule decides direction; position sizing decides magnitude. You can be right on direction more often than not and still go broke if you bet too big on the trades that go against you, because losses compound asymmetrically — a 50% drawdown needs a 100% gain to recover. The job of sizing is to keep every single loss small enough that no string of them can knock you out of the game, while still letting your winners compound. It is the part of the system that turns a fragile edge into a durable one.
This is also the part beginners most often hard-code as a flat "buy 1 BTC" and never revisit. That fixes your risk to whatever the market's volatility happens to be that week, which is exactly backwards. Good sizing holds your risk constant and lets the quantity float to match it.
Fixed-dollar vs fixed-fractional
The simplest schemes scale your bet to your account. With fixed-dollar sizing you risk a constant cash amount per trade — say $100 — regardless of how big the account grows or shrinks. It is easy to reason about, but it doesn't compound: a $100 risk is a different thing on a $2,000 account than on a $20,000 one, and after a losing streak you keep betting the same fixed sum on a shrinking balance.
Fixed-fractional sizing risks a constant percentage of current equity instead — typically 0.5% to 2% per trade. As the account grows, position size grows with it; as it shrinks, you automatically de-risk. This self-scaling property is why fixed-fractional is the default for almost every well-built retail bot, and it's exactly the calculation our position-size calculator performs.
The core position-size formula
Once you've chosen a risk fraction, the size of any trade falls out of one equation. You know the dollars you're willing to lose, and you know how far price has to move against you before your stop fires. Quantity is just the first divided by the second:
size = (account × risk%) ÷ |entry − stop|
Read it plainly: the numerator is the dollars at risk on this trade; the denominator is the dollars lost per unit if the stop is hit. Divide and you get the number of units that makes the loss-at-stop equal exactly your target risk. If a $10,000 account risks 1% ($100) on an entry at $50 with a stop at $48, the per-unit risk is $2, so the size is 100 ÷ 2 = 50 units. Move the stop to $49 and the same $100 of risk now buys 100 units — tighter stops permit larger positions, looser stops force smaller ones. The dollar risk never changes; only the quantity does.
Notice the formula needs your stop before it can size anything. A bot that decides quantity first and stop-loss second has the logic backwards. Define where you're wrong, then let the math tell you how much to hold.
Volatility-based (ATR) position sizing
A fixed price-based stop ignores that markets breathe differently from day to day. Volatility-based sizing fixes this by deriving the stop distance from a volatility measure — most commonly the Average True Range (ATR), the average size of a candle's range over a lookback window. You set the stop a multiple of ATR away from entry (e.g. 2 × ATR), then feed that distance into the same risk formula.
The elegant consequence: because position size is inversely proportional to the stop distance, and the stop distance tracks volatility, size moves inversely with volatility. When a market is wild and ATR is large, the bot takes a smaller position; when it's calm and ATR is small, it takes a larger one. Every trade ends up risking roughly the same number of dollars regardless of how choppy the market is — which is exactly what you want a portfolio of bots to do. Here's the sketch:
python · atr_size.pydef atr_position_size(account, risk_pct, entry, atr, mult=2.0):
# stop distance scales with current volatility
stop_dist = mult * atr # e.g. 2 x ATR
risk_usd = account * risk_pct # e.g. 10000 * 0.01 = 100
if stop_dist <= 0:
return 0.0 # never divide by zero
qty = risk_usd / stop_dist # the core formula
return qty
# calm market: small ATR -> bigger position
atr_position_size(10000, 0.01, entry=50, atr=0.5) # 100 units
# volatile market: large ATR -> smaller position
atr_position_size(10000, 0.01, entry=50, atr=2.0) # 25 units
Same $100 of risk in both cases — the volatile market simply earns a quarter of the quantity. This is the engine behind most trend-following and crypto bots, where volatility swings are enormous. It pairs naturally with the broader controls in trading bot risk management.
The Kelly criterion (and why fractional Kelly wins)
The Kelly criterion answers a different question: not "how do I cap risk?" but "what bet fraction maximises long-run compound growth?" Its intuition is captured by f* = edge ÷ odds — the fraction of capital to wager is your statistical edge divided by the odds you're being offered. A bigger edge says bet more; worse odds say bet less. For a simple win/loss bet it expands to f* = p − (1 − p)/b, where p is win probability and b is the payoff ratio of a win to a loss.
Kelly is mathematically optimal for growth, and that's precisely the trap. Full Kelly assumes you know p and b exactly — but in trading you only ever estimate them from noisy history, and you almost always estimate your own edge too high. Overstate the edge a little and full Kelly over-bets a lot, producing stomach-churning drawdowns that can exceed 50% even when the strategy is genuinely profitable. The path of full Kelly is just too violent for real capital and real psychology.
Almost nobody runs full Kelly on a live book. The standard move is half-Kelly or quarter-Kelly — bet a half or a quarter of what the formula says. You keep most of the long-run growth benefit while roughly halving the drawdowns and buying a large margin of safety against your edge being overestimated. Treat Kelly as an upper bound on sizing, not a target.
Equal-weight vs volatility-parity across bots
When you run several bots at once, you need a rule for splitting capital between them. The naive answer is equal-weight: give each strategy the same slice of the account. It's simple and transparent, but it quietly lets your most volatile bot dominate the portfolio's risk — a strategy trading a wild altcoin contributes far more swing than one trading a calm major, even at equal dollars.
Volatility-parity (risk-parity) instead allocates so that each bot contributes the same amount of risk, sizing inversely to each strategy's volatility just as ATR sizing does within a single trade. The calmer strategies get more capital, the wild ones get less, and no single bot can blow up the whole account on a bad week. For most multi-strategy setups, targeting equal risk contribution is more robust than targeting equal dollars.
Leverage, notional and rounding to lot sizes
Two practical details trip up live bots. First, leverage and notional: your risk is set by the stop distance and quantity, but your notional (quantity × price) is what the exchange and margin engine see. Leverage lets a small balance control a large notional — it changes your margin and liquidation math, not the dollars-at-risk that the sizing formula targets. Size from risk first, then check that the resulting notional and leverage are within your margin limits, never the other way around.
Second, lot-size rounding: exchanges enforce a minimum order size and a step size, so a raw quantity like 0.0473 BTC may need rounding to 0.047. Always round down to the nearest valid step — rounding up quietly pushes you over your risk target — and skip the trade entirely if the rounded size falls below the exchange minimum. A clean sizing function ends with this rounding step, not the formula.
If you're still assembling the loop these controls live in, start with how to build a trading bot, and judge the result on risk-adjusted terms using the Sharpe ratio rather than raw return.
Comparing the sizing methods
No single method is "best" — each trades simplicity against adaptiveness. Here's how the common approaches stack up:
| Method | How it sizes | Pro | Con |
|---|---|---|---|
| Fixed-dollar | Constant cash risk per trade | Dead simple to reason about | Doesn't compound; ignores account changes |
| Fixed-fractional | Constant % of equity via the risk formula | Self-scaling; auto de-risks in drawdowns | Needs a defined stop on every trade |
| Volatility / ATR | Stop = ATR multiple, size inverse to volatility | Equal dollar risk across calm & wild markets | ATR is backward-looking; lags regime shifts |
| Kelly (full) | f* = edge ÷ odds, growth-optimal | Maximises long-run compounding in theory | Brutal drawdowns; over-bets on overstated edge |
| Fractional Kelly | Half or quarter of full Kelly | Most of the growth, far less volatility | Still depends on estimating edge & odds |
| Volatility-parity | Equal risk contribution across bots | No single strategy dominates portfolio risk | More moving parts; needs ongoing rebalancing |
For most people the honest answer is: run fixed-fractional sizing, derive the stop from ATR, and let fractional Kelly inform an upper ceiling rather than your day-to-day bet. Simple, robust, and very hard to blow up with.
Frequently asked questions
What is the most common position sizing method for trading bots?
Fixed-fractional risk sizing is the workhorse for retail bots. You risk a small, constant fraction of equity per trade — often 0.5% to 2% — and derive the quantity from the distance between your entry and your stop. It's simple, self-scaling as equity changes, and very hard to blow up with.
How does ATR position sizing work?
ATR sizing sets the stop distance from the Average True Range so the stop adapts to current volatility, then solves the same risk formula for quantity. Because position size is inversely proportional to ATR, a wider, more volatile market gets a smaller position and a calm market a larger one — so every trade risks roughly the same dollar amount.
Should I use the full Kelly criterion to size trades?
Almost no practitioner runs full Kelly. It maximises long-run growth but produces violent drawdowns and is extremely sensitive to estimation error in your edge and odds — overstate your edge even slightly and full Kelly over-bets badly. Most who use it at all apply half-Kelly or quarter-Kelly to keep the growth benefit while cutting the volatility.
How do I handle exchange lot sizes when sizing a position?
Every market has a minimum order size and a step size. After your formula returns a raw quantity, round it down to the nearest valid step so the order is accepted, and skip the trade if the rounded quantity is below the exchange minimum. Rounding down rather than up keeps you from quietly risking more than your target.