Position Sizing in a Backtest
How Do You Size Positions in a Backtest?
Position size is the number of shares, contracts, or dollars you commit to each trade. It seems like a small detail, but it's absolutely crucial. Two traders with identical entry and exit rules will have completely different results if one sizes at 100 shares and the other at 1,000. Position size determines how much you win and lose on each trade, and therefore how much damage a losing streak can do. This article teaches you how to size positions in a backtest in a way that reflects real trading constraints and matches your risk appetite.
Quick definition: Position size is the number of shares, contracts, or dollar amount you commit to a trade, determined by a rule that balances capital availability, account risk, and market volatility.
Key takeaways
- Position size must be defined before the backtest; never size based on past results.
- Fixed position sizes (same number of shares every trade) are simple but don't adapt to volatility or account growth.
- Percentage-of-account sizing (risking a fixed % per trade) grows the position size as your account grows.
- Volatility-adjusted sizing adapts the position size to current market conditions.
- Position size affects drawdown, margin requirements, and the probability of ruin.
Fixed Position Sizing
The simplest position size is a fixed number of shares.
Example: 100 shares per trade. "Every trade is 100 shares, regardless of the stock price or volatility."
Fixed sizing is easy to understand and test. Every trade is identical in terms of share count. This has advantages:
- Simple to execute.
- Easy to track profit/loss per trade.
- No math required.
It also has disadvantages:
- A $200 stock and a $10 stock take the same number of shares, but the $200 stock means more capital at risk.
- In a backtest, you might quickly run out of margin or cash.
- As your account grows, 100 shares becomes a tiny position.
Fixed sizing works for small accounts or for traders with plenty of capital. For most traders, it's too rigid.
Fixed-Dollar Position Sizing
Instead of a fixed share count, you commit a fixed dollar amount.
Example: $10,000 per trade. "Every trade is $10,000 notional value. If the stock is $100, buy 100 shares. If the stock is $50, buy 200 shares."
This adapts to the stock price but keeps the dollar commitment constant. It's more flexible than fixed shares because it automatically adjusts the share count to the price.
In a backtest, fixed-dollar sizing is easy to implement. You just divide the dollar amount by the stock price to get the share count. The advantage is simplicity. The disadvantage is that it doesn't adapt to volatility. A $10,000 position in a quiet stock might be too small; a $10,000 position in a volatile stock might be too large.
Percentage-of-Account Position Sizing
The most realistic method is to size based on the account balance.
Example: Risk 1% of account per trade. "If the account is $100,000 and the stop loss is 2%, then risk $1,000 (1% of $100,000). The position size is calculated as: $1,000 ÷ 2% = $50,000 notional, or 500 shares at $100/share."
This method connects position size to account size and stop loss. As the account grows (or shrinks), the position size grows (or shrinks) automatically.
The math is simple:
- Position risk = Account balance × Risk per trade %
- Position size = Position risk ÷ Stop loss %
If the account is $100,000, you risk 1% ($1,000), and your stop is 2%, then the position is worth $50,000.
The advantages are:
- Grows with the account (successful trading automatically increases position size).
- Shrinks with the account (drawdowns automatically reduce position size, protecting capital).
- Scales to any account size.
The disadvantages are:
- Requires knowing your stop loss in advance.
- Can lead to very large positions in fast-moving, profitable periods (risky).
- Requires recalculating position size before each trade.
Volatility-Adjusted Position Sizing
The most sophisticated method adapts position size to current market volatility.
Example: Size based on ATR. "The 14-bar ATR is $2. Set position size so that a 1-ATR move equals 1% of account. Position size = (1% of account) ÷ (1 ATR)."
If the account is $100,000, one percent is $1,000. If ATR is $2 per share, then position size is $1,000 ÷ $2 = 500 shares.
If volatility increases and ATR becomes $3, then position size is $1,000 ÷ $3 = 333 shares. The position is smaller because the risk is higher.
Volatility-adjusted sizing is elegant because it respects market conditions:
- In quiet markets, you can size larger because the risk is smaller.
- In volatile markets, you size smaller to avoid oversized risk.
The downside is complexity: you need to calculate ATR for each stock before each trade.
Decision tree
Choosing the Right Risk Per Trade
Regardless of sizing method, you need to decide how much to risk per trade. This is critical.
Risk 0.5% per trade: Conservative. You can lose 200 trades before blowing up. Most traders don't lose 200 straight. This is safe but slow to grow capital.
Risk 1% per trade: Moderate. You can lose 100 trades before ruin. This is the most common choice.
Risk 2% per trade: Aggressive. You can lose 50 trades before ruin. Growth is faster, but drawdowns are severe.
Risk 5% per trade: Very aggressive. You can lose 20 trades before ruin. Ruin is common. Not recommended for most traders.
The choice depends on your edge (how profitable your system is) and your psychology. A trader with a 55% win rate and a 1.5:1 reward-to-risk ratio can afford to risk 2% per trade. A trader with a 50% win rate and a 1:1 ratio needs to risk 0.5% to stay solvent.
Position Sizing and Margin
In a backtest, account cash and margin limits matter.
If your backtest has a $100,000 account and you're trading on 2:1 margin (can control $200,000), your positions are limited to $200,000 notional value. If you have three $50,000 positions open, that's $150,000—you're within limits. If you try a fourth $50,000 position, you hit the margin limit and can't enter.
In your backtest, decide:
- How much cash am I starting with?
- What margin multiple am I allowed? (No margin, 2:1, 4:1, etc.)
- What happens if a position would violate margin? (Don't enter, or reduce size?)
Most honest backtests enforce margin limits. If you hit the limit, you can't enter until you close a position.
Position Sizing and Slippage
Larger positions are harder to execute. If you're trading 10,000 shares, you might impact the market, moving the price against you. In a backtest, you don't usually model this, but in real trading, it's a cost.
Assuming realistic slippage (see the article on slippage) means:
- Larger positions take longer to execute and may fill at worse prices.
- Smaller positions fill quickly and cleanly.
If your backtest assumes you fill instantly at the exact price, you're ignoring this cost. Reality is more expensive.
Fixed Sizing vs. Percentage Sizing in Backtests
Let's compare two backtests of the same strategy.
Backtest A: Fixed $10,000 per trade
- Trade 1: Win $100 (account: $100,100).
- Trade 2: Win $100 (account: $100,200).
- Trade 3: Lose $200 (account: $100,000).
Notice the account barely moves. You're risking a fixed amount, so you make and lose fixed amounts.
Backtest B: Risk 1% of account per trade, with 2% stop
- Account: $100,000. Risk: $1,000. Position size: $50,000.
- Trade 1: Win $500 (account: $100,500).
- Trade 2: Win $500 (account: $101,000).
- Trade 3: Lose $2,000 (stop hit, account: $99,000).
Notice the account grows faster after wins and shrinks faster after losses. This reflects real trading: winning increases your position size (good), but losing reduces it (bad in the moment, good for survival).
Kelly Criterion and Optimal Position Sizing
The Kelly Criterion is a mathematical formula that calculates the "optimal" position size given your win rate and reward-to-risk ratio.
Kelly % = (Win % × Avg Win) - (Loss % × Avg Loss) / Avg Win
Example: 55% win rate, average win $100, average loss $100. Kelly % = (0.55 × 100) - (0.45 × 100) / 100 = (55 - 45) / 100 = 10%
This says you should risk 10% of your account per trade. But there's a catch: Kelly is optimal mathematically but brutal psychologically. A 10% risk means you can lose 10 trades in a row and lose half your account. Most traders can't handle that emotionally.
Most traders use "half Kelly" or "quarter Kelly": 5% or 2.5% risk. This is slower but more survivable.
Real-World Position Sizing Examples
Example 1: Day Trader
Starting account: $25,000. Risk per trade: 1% ($250). Stop loss: 0.5% (on a $100 stock, $0.50). Position size = $250 ÷ 0.5% = $50,000 notional = 500 shares at $100.
Example 2: Swing Trader
Starting account: $100,000. Risk per trade: 2% ($2,000). Stop loss: 2% (wider, because holding longer). Position size = $2,000 ÷ 2% = $100,000 notional. But wait—that's the entire account in one trade. This trader would limit it to 25-50% of account.
Example 3: Position Trader
Starting account: $500,000. Risk per trade: 0.5% ($2,500). Stop loss: 3% (very wide, because holding for weeks). Position size = $2,500 ÷ 3% = $83,333 notional. Can hold 5-6 positions simultaneously without overexposing.
Position Sizing Mistakes in Backtests
Mistake 1: Martingale sizing. After a loss, increase the position size. This is the fastest way to blow up. If your strategy is losing, making bigger bets won't help.
Mistake 2: No sizing rule. Sizing "by feel" is not a rule. You must write down the rule before the backtest.
Mistake 3: Sizing too large. Risking 5% per trade means a 20-trade losing streak destroys the account. Most traders will lose 20 in a row at some point.
Mistake 4: Not accounting for multiple open positions. If you have 5 positions open and risk 2% on each, you're risking 10% of the account total. Make sure you track this.
Mistake 5: Changing the sizing rule after the backtest. You backtest with 1% risk, see the results, and think "if I had risked 2%, I would have made twice as much." That's technically true, but it's also True that you would have blown up twice as fast in a bad streak. Don't optimize sizing based on past results.
FAQ
Should I size the same for every stock?
Yes, use the same rule for every stock. If your rule is "risk 1% per trade," apply it to Apple and a penny stock the same way. The position size will be different (fewer shares of Apple, more of the penny stock) but the risk is the same.
What if the position size is too small to meet the stock's trading limits?
Most stocks have a minimum order. If the position size calculates to 1 share and the minimum is 100, either increase account size, increase risk per trade, or skip that stock. Don't violate your rules to force a trade.
Should I scale into a position or buy all at once?
For a backtest, assume you buy all at once. Scaling is a real technique (buy 50% now, 50% on confirmation), but it's more complex to test.
Can I use different position sizes for different strategies?
If you're testing two different strategies (breakout and mean reversion), you can size them differently if you write the rule. But within one strategy, use consistent sizing.
What's the relationship between position size and drawdown?
Larger position size = larger drawdowns. If you size aggressively (2-5% per trade), a losing streak might draw down 30-50% of your account. If you size conservatively (0.5%), the drawdown is smaller. Backtest to see the drawdown and ask yourself: could I handle it psychologically?
Should position size be based on account balance or initial account balance?
Use current account balance. If the account grows to $150,000, risk 1% of $150,000 on the next trade, not 1% of the original $100,000. This lets profits compound.
Related concepts
- Defining Rules Before Backtesting — Position sizing is part of your overall rules.
- Stop Loss Rule in a Backtest — Stop loss and position size work together to determine risk.
- Risk of Ruin Overview — Position size directly affects the probability of losing your account.
- Slippage Assumption in a Backtest — Larger positions have higher slippage.
Summary
Position size determines how much you win and lose on each trade. It should be defined by a rule, not by feel. The simplest methods are fixed share count or fixed dollar amount. The most realistic method is percentage-of-account sizing, where you risk a fixed percentage (usually 1-2%) of your account on each trade. Volatility-adjusted sizing adapts the position to current market conditions. In your backtest, enforce margin limits and realistic position constraints. Larger position sizes grow the account faster but increase drawdowns. Too-large sizing (5%+ per trade) leads to ruin in almost any trading career. Choose a sizing rule, write it down, test it, and don't change it based on past results. The goal is a position size that you could actually trade without panic, and that lets your account survive bad luck.