Binary Strategies
Binary strategies are strategies that reason about singular binary bets. These bets have some payoff if they win, some loss if they lose, and a transaction cost regardless. Bets are not continuous, they either win or lose.
Base Strategy
- class keeks.binary_strategies.base.BaseStrategy(payoff: float, loss: float, transaction_cost: float = 0)[source]
Bases:
ABC
Abstract base class for all binary betting strategies.
This class defines the interface that all binary betting strategies must implement. Concrete strategy implementations should inherit from this class and implement the evaluate method.
Naive Strategy
- class keeks.binary_strategies.simple.NaiveStrategy(payoff, loss, transaction_cost)[source]
Bases:
BaseStrategy
A simple betting strategy that bets based on expected value.
This strategy calculates the expected value of a bet and bets a fixed fraction of the bankroll if the expected value is positive.
- Parameters:
Fixed Fraction Strategy
- class keeks.binary_strategies.simple.FixedFractionStrategy(fraction, payoff, loss, transaction_cost=0, min_probability=0.5)[source]
Bases:
BaseStrategy
A simple strategy that bets a fixed percentage of the bankroll.
This strategy ignores probabilities and odds completely, and simply wagers a fixed fraction of the bankroll. It can be used as a baseline for comparison or as a simple approach for risk management.
- Parameters:
fraction (float) – The fixed fraction of the bankroll to bet (between 0 and 1).
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float, default=0) – The fixed cost per transaction, regardless of outcome.
min_probability (float, default=0.5) – The minimum probability required to place a bet.
CPPI Strategy
- class keeks.binary_strategies.simple.CPPIStrategy(floor_fraction, multiplier, initial_bankroll, payoff, loss, transaction_cost=0, min_probability=0.5)[source]
Bases:
BaseStrategy
Implementation of Constant Proportion Portfolio Insurance (CPPI) for binary betting.
This strategy maintains a dynamic floor below which the bankroll should not fall, and invests a multiple of the cushion (amount above floor) in each bet.
- Parameters:
floor_fraction (float) – The fraction of initial bankroll to maintain as a floor.
multiplier (float) – The multiplier to apply to the cushion for determining exposure.
initial_bankroll (float) – The initial bankroll amount.
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
min_probability (float, default=0.5) – The minimum probability required to place a bet.
Dynamic Bankroll Management
- class keeks.binary_strategies.simple.DynamicBankrollManagement(base_fraction, payoff, loss, transaction_cost, window_size=10, max_fraction=0.2, min_fraction=0.05)[source]
Bases:
BaseStrategy
A dynamic bankroll management strategy that adjusts bet sizes based on performance.
This strategy adjusts the base bet fraction based on: 1. Recent performance (win/loss streak) 2. Volatility of returns 3. Current drawdown level 4. Probability of success
- Parameters:
base_fraction (float) – The base fraction of bankroll to bet.
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
window_size (int, default=10) – The number of recent results to consider for adjustments.
max_fraction (float, default=0.2) – The maximum fraction of bankroll that can be bet.
min_fraction (float, default=0.05) – The minimum fraction of bankroll to bet.
Kelly Criterion
- class keeks.binary_strategies.kelly.KellyCriterion(payoff, loss, transaction_cost, min_probability=0.5)[source]
Bases:
BaseStrategy
Implementation of the Kelly Criterion for binary betting.
The Kelly Criterion is a mathematical formula that determines the optimal size of a series of bets to maximize long-term growth rate.
- Parameters:
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
min_probability (float, default=0.5) – The minimum probability required to place a bet.
Fractional Kelly Criterion
- class keeks.binary_strategies.kelly.FractionalKellyCriterion(payoff, loss, transaction_cost, fraction)[source]
Bases:
BaseStrategy
Implementation of the Fractional Kelly Criterion for binary betting.
The Fractional Kelly Criterion applies a fraction to the full Kelly bet size, which can reduce volatility at the expense of long-term growth rate.
- Parameters:
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
fraction (float) – The fraction of the full Kelly bet to use (typically between 0 and 1).
Drawdown-Adjusted Kelly
- class keeks.binary_strategies.kelly.DrawdownAdjustedKelly(payoff, loss, transaction_cost, max_acceptable_drawdown=0.2)[source]
Bases:
BaseStrategy
Implementation of the Drawdown-Adjusted Kelly Criterion for binary betting.
This strategy adjusts the Kelly bet size based on a maximum acceptable drawdown. It provides a more conservative approach by reducing the bet size to minimize the risk of large drawdowns.
- Parameters:
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
max_acceptable_drawdown (float) – The maximum acceptable drawdown as a fraction of the bankroll (0 to 1).
OptimalF
- class keeks.binary_strategies.simple.OptimalF(payoff, loss, transaction_cost, win_rate, max_risk_fraction=0.2)[source]
Bases:
BaseStrategy
Implementation of the Optimal f strategy for binary betting.
This strategy calculates the optimal fraction of bankroll to bet based on the win rate and payoff ratio. It’s similar to Kelly but uses a different approach to risk management.
- Parameters:
payoff (float) – The amount won per unit bet on a successful outcome.
loss (float) – The amount lost per unit bet on an unsuccessful outcome.
transaction_cost (float) – The fixed cost per transaction, regardless of outcome.
win_rate (float) – The historical or expected win rate (between 0 and 1).
max_risk_fraction (float, default=0.2) – The maximum fraction of bankroll that can be risked on a single bet.