Based on: Kelly, J. L., Jr. (1956). "A New Interpretation of Information Rate." Bell System Technical Journal, 35(4), 917–926. doi:10.1002/j.1538-7305.1956.tb03809.x
A stupidly fast, native C++ Python extension implementing the Kelly Criterion for optimal bet (but lets call them 'investments' instead) sizing.

pip install kelzerimport kelzerReturns the optimal fraction of bankroll to wager.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
win_prob |
float | yes | — | Probability of winning, in (0, 1) |
decimal_odds |
float | yes | — | Decimal odds, must be > 1 |
multiplier |
float | no | 1.0 | Fraction of Kelly to apply, in (0, 1] |
decimals |
int | no | 4 | Decimal places to round result to (0–15) |
import kelzer
# Full Kelly — 60% chance at 2.0 odds
kelzer.fraction(0.6, 2.0)
# 0.2
# Quarter Kelly
kelzer.fraction(0.6, 2.0, multiplier=0.25)
# 0.05
# Half Kelly, 6 decimal places
kelzer.fraction(0.55, 1.9, multiplier=0.5, decimals=6)
# 0.055556
# Negative edge — don't bet
kelzer.fraction(0.3, 2.0)
# -0.4kelzer.fraction(0.0, 2.0) # ValueError: win_prob must be in (0, 1)
kelzer.fraction(0.6, 1.0) # ValueError: decimal_odds must be > 1
kelzer.fraction(0.6, 2.0, multiplier=0.0) # ValueError: multiplier must be in (0, 1]f* = (b·p − q) / b
Where b = decimal_odds − 1, p = win_prob, q = 1 − p. The result is then scaled by multiplier.
Apache 2.0