Skip to content

Instantly share code, notes, and snippets.

@isaacharrisholt
Created May 23, 2021 16:40
Show Gist options
  • Save isaacharrisholt/9abf2f47d5b201ea8c26420ca2e2a1af to your computer and use it in GitHub Desktop.
Save isaacharrisholt/9abf2f47d5b201ea8c26420ca2e2a1af to your computer and use it in GitHub Desktop.
Calculate surebet stakes for a two-way market
# Unrounded calculations for two way bets
def two_way_unrounded_calculations(odds1, odds2, total_stake):
x, y = symbols('x y')
# Equation for total stake
total_stake_eq = Eq(x + y - total_stake, 0)
# Odds multiplied by their stake must be equal
individual_stakes_eq = Eq((odds2 * y) - (odds1 * x), 0)
# Solve equations to get stakes and return
stakes = solve((total_stake_eq, individual_stakes_eq), (x, y))
stake1 = float(stakes[x])
stake2 = float(stakes[y])
return stake1, stake2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment