Skip to main content

Programming with betting odds, made simple

Project description

Degen

Programming with betting odds, made simple

pronounced "dee-gen" as in Degenerate Gambler

alt text Code style: black

Table of Contents

  1. Installation
  2. Getting Started
  3. Examples
  4. Developing / Contributing

Installation

pip install degen

Getting Started

from degen import AmericanOdds

odds = AmericanOdds(-110)
print(odds.value)
# >>> -110

Easy conversion between odds types

There are 3 main Odds types provided by degen:

  • AmericanOdds
  • DecimalOdds
  • ImpliedProbability

They all support the methods:

  • .to_american_odds()
  • .to_decimal_odds()
  • .to_implied_probability()

No more formulas

Examples

Example 0: simple odds objects

from degen import AmericanOdds, DecimalOdds, ImpliedProbability

american_odds = AmericanOdds(-110)

decimal_odds: DecimalOdds = american_odds.to_decimal_odds()
print(decimal_odds.value)
# >>> 1.909090909090909090909090909

implied_probability: ImpliedProbability = american_odds.to_implied_probability()
print(implied_probability.value)
# >>> 0.5238095238095238095238095238

Example 1: Bitwise operators for simple odds computation, parlay using bitwise-and operator

odds1 = AmericanOdds(-110)
odds2 = AmericanOdds(-110)

parlay_odds: AmericanOdds = odds1 & odds2
print(parlay_odds.value)
# >>> 264.4628099173553719008264463

Example 2: Computing juice or the vig using the bitwise-or operator

juice = AmericanOdds(-110) | AmericanOdds(-110)

# Juice can't be represented by american odds, so the type of the juice 
# variable will be "ImpliedProbability" after the computation, which is still an Odds type. 
print(type(juice))
# >>> <class 'degen.odds_models.ImpliedProbability'>

# ImpliedProb > 1.0 provides a measure of "juiced" odds, or the book "vig"
print(juice.value)
# >>> 1.047619047619047619047619048

# You can ask all odds objects if they're "juiced"
print(juice.is_juiced)
# >>> True

Contributing / Developing

Install requirements

pip install -r requirements-dev.txt -r requirements.txt

Run tox suite:

  • Run black code fmt checks
  • Run unittests
  • Check coverage
  • Generate coverage report & badge
tox

Test coverage has a floor of 95% - this will block a PR from getting approval if this threshold isn't met.

Todo

Contributions from other developers are always welcome, here are some things that need to be implemented:

  • Fractional Odds
  • Hong Odds

Notes

  • Everythign done with Decimals for numerical precision

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

degen-0.1.6.tar.gz (5.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page