DEV Community

pickuma
pickuma

Posted on • Originally published at pickuma.com

Position Sizing with the Kelly Criterion: A Developer's Guide

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 reason you can't just maximize expected return is that losses and gains compound multiplicatively. A 50% loss requires a 100% gain to recover. Kelly is built around that asymmetry — it's the bet size where the math of compounding works for you instead of against you.

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.

Treat full Kelly as a theoretical ceiling, not a target. Because real edge estimates are noisy and overstated, most disciplined traders size at half-Kelly or less. Betting full Kelly on an estimated edge is a fast way to discover your estimate was wrong — with real money.

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.

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


Originally published at pickuma.com. Subscribe to the RSS or follow @pickuma.bsky.social for new reviews.

Top comments (0)