Kelly criterion bet size: a convex optimization example, solved and checked
The Kelly criterion bet size is a classic convex optimization problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.
Solve your own version free, no account needed
The problem
A bet pays even money and wins with probability 0.6. What fraction of your bankroll should you stake each time to maximize long-run growth?
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
- Staking a fraction f of the bankroll, a win multiplies it by 1 + f and a loss by 1 − f.
- Long-run growth per bet is the expected log of that factor: 0.6 log(1 + f) + 0.4 log(1 − f). Logs turn the product of many bets into a sum, which is why growth is measured with them.
The model
Each line has a plain-language note on the right.
| make this as large as possible | |
| fraction of bankroll staked on each bet (fraction) cannot be negative | |
| fraction of bankroll staked on each bet (fraction) is at most 0.99 |
What is being decided
There is one decision variable.
| Variable | Type | Meaning |
|---|---|---|
| f | real number | fraction of bankroll staked on each bet (fraction) |
Goal and limits
Maximize the objective subject to 2 constraints, of which 2 are simple bounds on a single variable.
Problem type
Conic (convex), complexity level 4: convex nonlinear functions such as log, exp, square roots or powers. Solved with CLARABEL at the Medium solver tier.
The answer at a glance
The optimal value of each decision, as the solver returned it.
Which constraints hold the answer in place
No constraint is binding. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | f >= 0 | 0.200024 | 0 | 0.200024 | |
| 2 | f <= 0.99 | 0.200024 | 0.99 | 0.789976 |
Algebraic model (low level)
Decision variables, objective and every constraint written out; this is exactly what the solver receives.
Model code (cvxpy)
The same model in cvxpy, ready to run.
import cvxpy as cp
f = cp.Variable(name='f') # fraction of bankroll staked on each bet (fraction)
objective = cp.Maximize(0.4*cp.log(1 - f) + 0.6*cp.log(f + 1))
constraints = [
f >= 0,
f <= 0.990000000000000,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('f =', f.value)Solve your own
This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).
maximize 0.6*log(1 + f) + 0.4*log(1 - f)
subject to
f >= 0
f <= 0.99
# f = fraction of bankroll staked on each bet (fraction)
# asked: optimal stake fraction fChecked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, SCS) agree on. Built 2026-11-10.
Related examples
Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.