The idea
Suppose you have a genuine edge: a bet that wins more often than it loses. The next question is not whether to bet but how much. Stake too little and you waste the edge. Stake too much and a few bad days can wipe you out, even though each bet is favourable.
The Kelly criterion answers this by choosing the stake that maximises the average logarithm of wealth, which is the same as the fastest long-run compounding. Because wealth multiplies bet after bet, the right thing to maximise is growth rate, not average profit.
In this module we compute the Kelly fraction for a simple coin-style bet, plot growth against stake size, and simulate 500 paths of 1000 bets to see over-betting ruin. Everything here is illustrative simulated data, and it is education, not advice.
- Kelly maximises expected log growth of wealth, i.e. the long-run compounding rate.
- For a bet with win chance p, loss chance q and net odds b, the Kelly fraction is (b×p − q) / b.
- Growth rises up to the Kelly stake and then falls; far beyond it, growth turns negative despite a positive edge.
- Over-betting raises the share of paths that finish below the starting wealth in the simulation.
- Kelly needs p and b to be known; with estimated edges, fractional Kelly such as half-Kelly is a common safeguard.
- Kelly sizing assumes repeated independent bets with known odds, which real markets rarely give you.
The maths
The optimal stake fraction is your edge (expected profit per rupee) divided by the net odds.
Each win multiplies wealth by 1 + bf and each loss by 1 − f, so g is the average log growth per bet.
Setting the derivative of the growth function to zero gives the Kelly fraction.
Wealth after n bets is the starting wealth times the exponential of the summed log returns, which is what the simulation computes.
The code
Every number on this page comes from this program. Press Run to execute it in your browser. You can edit the code and run it again.
import numpy as np
rng = np.random.default_rng(7)
p, b = 0.55, 1.0 # win chance, net odds
q = 1 - p
print('lose chance q:', round(q, 2))
kelly = (b*p - q) / b
print('Kelly fraction:', round(kelly, 3))
def g(f): # expected log growth per bet
return p*np.log(1+b*f) + q*np.log(1-f)
ms = [0.5, 1, 2, 3]
for m in ms:
print(m, 'x Kelly growth:', round(g(m*kelly), 5))
# simulate 500 paths of 1000 bets each
wins = rng.random((500, 1000)) < p
for m in ms:
f = m * kelly
lg = np.where(wins, np.log(1+b*f), np.log(1-f))
end = 10000 * np.exp(lg.sum(axis=1))
print(m, 'x | median', round(np.median(end)),
'| lost', round((end < 10000).mean(), 3)) lose chance q: 0.45 Kelly fraction: 0.1 0.5 x Kelly growth: 0.00375 1 x Kelly growth: 0.00501 2 x Kelly growth: -0.00014 3 x Kelly growth: -0.0162 0.5 x | median 426321 | lost 0.01 1 x | median 1496601 | lost 0.082 2 x | median 8713 | lost 0.516 3 x | median 0 | lost 0.954
We start with a win chance p of 0.55 and even-money odds b of 1.0, then print the lose chance q (0.45) and the Kelly fraction, which comes out as 0.1 of wealth.
The function g(f) gives expected log growth per bet for any stake f. We print it for half, one, two and three times Kelly. Growth is highest at the Kelly stake and falls away as the multiple rises beyond it, eventually going negative.
Then we simulate 500 paths of 1000 bets each, starting with 10,000 rupees. Each bet multiplies wealth by 1 + bf for a win or 1 − f for a loss. Summing the logs and exponentiating gives ending wealth. For each multiple we print the median ending wealth and the fraction of paths that finished below 10,000. Over-betting shows up as a rising fraction of losing paths, even though every bet has a positive edge.
In practice
Kelly sizing comes from information theory and gambling research and is used by systematic traders, poker players and some fund managers as a framework for position sizing. In India, a trader running a futures or options strategy might use it to think about how much capital to risk per trade, keeping in mind margin rules, STT and brokerage costs that reduce the true edge.
The limits are serious. You never know p and b exactly; overestimating your edge makes full Kelly an over-bet. Returns on markets are not independent coin flips, and fat tails and gaps make losses bigger than modelled. Full Kelly also produces large drawdowns, so practitioners often use a fraction such as half-Kelly, accepting lower growth for a smoother path. This is a teaching framework, not a recommendation.
Common mistakes
- Treating Kelly as maximising average profit; it maximises average log growth, which is more cautious.
- Plugging in an optimistic estimated edge: an overestimated p pushes you into over-betting.
- Assuming more than Kelly is just more aggressive; beyond it, growth actually falls and ruin becomes likely.
- Ignoring costs such as brokerage and STT, which shrink the real edge.
- Applying Kelly to bets that are not independent or repeated, such as a one-off concentrated position.
Exercises
Try each one in the code cell above before opening the answer.
1. If p = 0.5 and b = 1.0, what does the Kelly formula say about the stake?
The edge b×p − q equals 0.5 − 0.5 = 0, so f* = 0. With no edge, Kelly says do not bet.
2. In the program, change p to a value below 0.5 and rerun. What happens to the Kelly fraction and why should you not use it directly?
The formula gives a negative number, meaning the edge is against you. You should not bet at all (stake zero); a negative stake would mean taking the other side, which is a different bet.
3. Modify the loop to test half-Kelly with 500 new paths and compare the lost fraction with the full Kelly line. What do you expect?
Half-Kelly should have a lower fraction of paths that finish below the start and a smaller spread of outcomes, while giving up some median growth. Check this against the printed lines for the 0.5 and 1 multiples.
Interview questions
The kind of question asked in quant, risk and trading interviews, with a model answer.
What does the Kelly criterion maximise?
The expected logarithm of wealth per bet, which equals the long-run compounding growth rate. It is not the expected profit.
Why is over-betting worse than under-betting by the same amount?
The growth curve is asymmetric: it falls steeply after the peak and eventually goes negative, while under-betting still keeps positive growth, only slower.
Why do practitioners use half-Kelly?
The edge is estimated with error, and full Kelly has big drawdowns. Half-Kelly gives up some growth for a much smaller risk of over-betting and a smoother path.
Mini project
BUILD IT YOURSELF
Kelly Stake Explorer
Extend the program into a tool that explores how stake size, edge uncertainty and odds affect growth and ruin.
- Wrap the simulation in a function taking p, b and a multiple of Kelly.
- Add a finer grid of multiples and print growth and lost fraction for each.
- Make the true win chance differ from the estimated one and see how over-estimation hurts.
- Record the maximum drawdown on each path and compare multiples.
- Add a transaction cost to each bet and recompute the Kelly fraction.
- Write a short summary of which multiple you would find tolerable and why.
FAQ
Is the Kelly criterion investment advice?
No. It is a mathematical result about repeated bets with known odds. This lesson is education only.
Can I use Kelly for stocks?
A version exists for continuous returns, but it needs estimates of mean and variance that are noisy, so the result is unreliable. Treat it as a framework, not a rule.
Why does a positive edge still lead to losses?
Because losses and gains multiply. Large stakes make a losing streak damage wealth more than the same winning streak repairs it, so growth can turn negative.
Related
Education only. Not investment, tax or trading advice. Simulated results are illustrations; past data does not predict future returns.