Position Sizing with the Kelly Criterion: A Developer's Guide
The Kelly criterion gives a mathematically optimal bet size, but applied naively to trading it will ruin you. Here's the intuition, the formula, and why almost everyone uses a fraction of it.
Most retail traders blow up not because their signal was wrong but because they bet too much on it. Position sizing is the part of trading that quietly decides whether a decent edge compounds or detonates, and the Kelly criterion is the cleanest formal answer to “how much should I bet?” It’s also routinely misapplied. This is the developer’s-eye view: the intuition, the formula, and the reason nobody sane uses it at full strength. None of this is investment advice.
What Kelly is actually optimizing
The Kelly criterion answers a specific question: given a bet with a known edge, what fraction of your capital should you wager to maximize the long-run growth rate of that capital? Crucially, it maximizes geometric growth, not expected value. That distinction is the whole point.
You could maximize expected value by betting everything on any positive-edge bet. Do that repeatedly and a single loss wipes you out — and over many bets, ruin becomes near-certain. Kelly instead maximizes the compound growth rate, which inherently penalizes the risk of catastrophic drawdown. It finds the bet size that grows your bankroll fastest without betting so much that variance eats the compounding.
The formula
For a simple bet with a probability p of winning, a probability q = 1 - p of losing, and odds b (you win b times your stake on a win, lose your stake on a loss), the optimal fraction of capital to bet is:
f* = (b * p - q) / b
A few sanity checks make the formula intuitive. If your edge is zero (the bet is fair), f* comes out to zero — Kelly tells you not to bet. As your edge grows, f* grows. If the expected value is negative, f* goes negative, meaning the only “optimal” move is to take the other side or not play.
For trading, where outcomes aren’t a single binary payoff, there’s a continuous version expressed in terms of expected return and variance: roughly, the optimal fraction is your expected excess return divided by the variance of returns. The shape is the same — more edge means more size, more uncertainty means less.
Why full Kelly will hurt you
Here’s the part the formula won’t tell you: full Kelly is brutally volatile, and in real trading it’s usually wrong because its inputs are wrong.
Kelly assumes you know your edge and odds. In trading you don’t — you estimate them from noisy historical data, and those estimates are biased upward by the same overfitting and survivorship issues that plague backtests. Plug an overestimated edge into Kelly and it tells you to bet far too much. The formula is only as trustworthy as your probability estimate, and your probability estimate is a guess wearing a number’s clothing.
Even with perfect inputs, full Kelly produces drawdowns most people can’t psychologically or financially tolerate — routine 50%+ peak-to-trough swings. That’s why the standard practice is fractional Kelly: bet some fraction (commonly half or a quarter) of the Kelly amount. Half-Kelly captures roughly three-quarters of the growth rate with dramatically lower volatility, and it builds in a margin for the fact that your edge estimate is probably too optimistic.
Using it without getting hurt
If you’re building position sizing into a strategy, the responsible pattern is: estimate your edge conservatively, compute the Kelly fraction, then scale it down by a safety factor (half or quarter), and cap any single position regardless of what the formula says. Recompute as your edge estimate updates, and never let the math override basic risk limits like maximum portfolio concentration.
Kelly is best understood as a discipline, not a dial. It forces you to be explicit about your edge and your odds, and the moment you do that honestly, you usually realize your edge is smaller and noisier than you’d assumed — which is exactly the realization that keeps you solvent.
FAQ
Should I ever bet full Kelly?+
How do I estimate the inputs for trading?+
Does Kelly work for a portfolio of positions?+
The Kelly criterion is one of the few pieces of trading math that’s both elegant and genuinely useful. Just remember what it optimizes, and that its honest answer to “how much should I bet?” is almost always “less than you think, and less than the formula says.”
Related reading
2026-06-08
Alpaca API Review: Commission-Free Automated Trading for Developers in 2026
Alpaca markets itself as an API-first brokerage. After building against it, here's where the developer experience shines, where paper trading hides real-world friction, and who it's actually for.
2026-06-08
IBKR vs Alpaca for Automated Retail Trading in 2026
Interactive Brokers and Alpaca sit at opposite ends of the brokerage-API spectrum: depth and complexity versus simplicity and speed. Here's how to choose based on what you're actually building.
2026-06-08
The SEC EDGAR API: Free Fundamental Data for Developers
Before you pay for a fundamentals API, know that the SEC gives away structured financial-statement data through EDGAR. Here's what the API offers, its quirks, and how to actually use it.
2026-06-08
Tiingo vs EODHD vs Databento: Market Data APIs Beyond the Usual Two
Polygon and Alpha Vantage get all the attention, but Tiingo, EODHD, and Databento each fill a different gap for retail quants. Here's how they compare on coverage, cost, and what you actually get.
2026-06-05
The Best Books on Behavioral Finance and Market History (2026)
Four research-backed books on why markets misbehave and why investors do — bubbles, manias, cognitive bias, and fractal risk — chosen for readers who want history and psychology, not stock tips.
Get the best tools, weekly
One email every Friday. No spam, unsubscribe anytime.