↓ Skip to main content

stakepd.kelly_criterion

213 words·1 min
spd.kelly_criterion(odds, true_probability, odds_type, bank_roll=100.0, kelly_percentage=1.0)

Calculate the amount to bet on a positive expected value (EV) bet according to the Kelly Criterion formula.

Parameters:

  • odds (float, int, or pandas.Series): Scalar or Series of odds in odds_type format. Must match the type of true_probability.
  • true_probability (float or pandas.Series): Scalar or Series of estimated true probabilities of events.
  • odds_type (str): Type of odds provided. Supported values are 'decimal', 'fractional', and 'american'.
  • bank_roll (float, optional): Total bankroll available for betting. Default is 100.0.
  • kelly_percentage (float, optional): Kelly fraction as a decimal for fractional Kelly sizing. Default is 1.0 (full Kelly).

Returns:

  • float: Amount to wager according to the Kelly Criterion, or
  • pandas.Series: Series of Kelly wager values with the same length as true_probability and odds.

A returned value of 0.0 means the bet has no positive edge and should not be placed.

Example (no edge):

import pandas as pd
import stakepd as spd

bankroll = 100
odds = pd.Series([2.0, 3.0])
probabilities = pd.Series([0.4, 0.3])
wagers = spd.kelly_criterion(odds, probabilities, 'decimal', bankroll)
print(wagers)
0    0.0
1    0.0
dtype: float64

Example (positive edge):

import pandas as pd
import stakepd as spd

bankroll = 1000
odds = pd.Series([2.0, 3.0, 1.5])
probabilities = pd.Series([0.6, 0.4, 0.7])
wagers = spd.kelly_criterion(odds, probabilities, 'decimal', bankroll)
print(wagers)
0    200.0
1    100.0
2    100.0
dtype: float64