Keeks 0.1.0 Release: Optimal Bankroll Management Made Simple
I’m excited to announce the release of Keeks 0.1.0, my Python library for optimal bankroll allocation and betting strategies.
If you’ve ever wondered how to mathematically optimize your betting or investment strategy, Keeks might be just what you’ve been looking for.
What is Keeks?
Keeks is a Python package that makes it dead simple to implement and test various betting and investment strategies, with a particular focus on the Kelly Criterion and its variants. It’s designed for anyone who needs to make decisions about capital allocation:
- Sports bettors looking to optimize their bet sizing
- Traders managing portfolio allocations
- Researchers studying decision theory
- Gamblers wanting to understand the math behind optimal betting
- Anyone curious about the science of risk management
The name “Keeks” is a playful nod to the Kelly Criterion, which is at the heart of the library. My sister Kelly is Aunt Kiki or Keeks to all the kids, so it seemed like a fun name.
What’s in the box?
Keeks comes packed with several betting strategies:
- Kelly Criterion - The mathematically optimal strategy for maximizing the logarithm of wealth
- Fractional Kelly - A more conservative version that reduces volatility
- Drawdown-Adjusted Kelly - A variant that adjusts bet sizing based on risk tolerance
- OptimalF - Ralph Vince’s strategy that maximizes geometric growth rate
- Fixed Fraction - Simple strategy that bets a constant percentage of the bankroll
- CPPI - Constant Proportion Portfolio Insurance for protecting a floor value
- Dynamic Bankroll Management - Adaptive strategy based on recent performance
- Naive Strategy - A simple strategy for comparison purposes
Plus tools for:
- Bankroll management - Track and manage your funds with built-in protection against excessive losses
- Simulation - Test your strategies under different conditions before risking real money
- Visualization - Plot and compare the performance of different strategies
How do you use it?
Getting started with Keeks is straightforward. Here’s a quick example:
from keeks.bankroll import BankRoll
from keeks.binary_strategies.kelly import KellyCriterion
from keeks.simulators.repeated_binary import RepeatedBinarySimulator
# Create a bankroll with initial funds
bankroll = BankRoll(initial_funds=1000.0, max_draw_down=0.3)
# Create a Kelly Criterion strategy
strategy = KellyCriterion(payoff=1.0, loss=1.0, transaction_cost=0.01)
# Create a simulator with a fixed probability
simulator = RepeatedBinarySimulator(
payoff=1.0,
loss=1.0,
transaction_costs=0.01,
probability=0.55, # 55% chance of winning
trials=1000
)
# Run the simulation
simulator.evaluate_strategy(strategy, bankroll)
# Plot the results
bankroll.plot_history()
This example simulates 1,000 bets using the Kelly Criterion, where each bet has a 55% chance of winning. The results are then visualized to show how your bankroll would have performed.
Why I built Keeks
I’ve always been fascinated by the mathematics of betting and investment. The Kelly Criterion, in particular, represents this beautiful intersection of information theory, probability, and finance.
What started as a personal project to better understand these concepts evolved into a full-fledged library that I thought others might find useful. Whether you’re a professional bettor or just someone curious about optimal decision-making under uncertainty, I hope Keeks can be a valuable tool in your arsenal.
What’s new in 0.1.0?
Since this is the first proper release of Keeks, everything is new! But compared to the previous development versions (0.0.1 and 0.0.2), here’s what’s changed:
- Added comprehensive documentation and examples
- Implemented multiple new betting strategies beyond just Kelly
- Added simulation tools for testing strategies under different conditions
- Created visualization tools for comparing strategy performance
- Improved bankroll management with drawdown protection
- Added support for transaction costs in strategy calculations
- Comprehensive test suite and CI/CD pipeline
- Performance optimizations for large simulations
Installation
Getting Keeks is as simple as:
pip install keeks
If you’re feeling fancy and want the latest development version:
pip install git+https://github.com/wdm0006/keeks.git
Where to find more
- GitHub: https://github.com/wdm0006/keeks
- Documentation: https://keeks.mcginniscommawill.com
The math behind Keeks
For those interested in the theory, Keeks is based on some fascinating mathematical principles. The Kelly Criterion, for instance, was originally developed by John L. Kelly Jr. at Bell Labs in 1956 as a way to optimize information transmission over noisy channels. It was later applied to gambling and investment by mathematicians and economists.
The basic formula for the Kelly Criterion is surprisingly simple:
f* = (p * b - q) / b
Where:
f*
is the fraction of your bankroll to betp
is the probability of winningq
is the probability of losing (1 - p)b
is the net odds received on the bet (payout for a $1 bet)
What makes this formula powerful is that it maximizes the expected logarithm of wealth, which in the long run leads to faster growth than any other strategy.
Of course, the real world is messier than this simple formula suggests, which is why Keeks implements various modifications and alternatives to handle things like transaction costs, drawdown risk, and uncertainty in probability estimates.
Get involved!
Contributions and feedback are always welcome! Whether you want to report a bug, request a feature, or submit a pull request, head over to the GitHub repository and get involved.
I’m particularly interested in hearing about how people are using Keeks in the wild. If you’ve built something cool with it, drop me a line!
Thanks for checking out Keeks. May your bankroll always grow and your drawdowns be minimal! 🎲📈