A library of betting utilities to assist with calculation of bets, stakes and markets
Project description
pybet
pybet is a library of betting utilities to assist with calculation of bets, stakes and markets
Installation
pip install pybet
Usage
This initial release contains an Odds class which enables conversion from and to the following types of odds or odds-equivalent:
- Decimal odds, e.g. 2.5
- Fractional odds, e.g. 6/4
- American moneyline odds, e.g. +150
- Implied percentage, e.g. 40
- Implied probability, e.g. 0.4
Internally, the value of an Odds instance is stored as a Decimal, making decimal odds the effective default. Odds can be instantiated directly as decimals or via a class method, specifying the type of odds being instantiated from. Any Odds instance can then be output to any type with a to_{type} method, e.g.
from pybet import Odds
o = Odds(2.5)
o.to_moneyline() # +150
o.to_percentage() # 40
o = Odds.fractional(6, 4)
o.to_probability() # 0.4
The to_fractional() method requires a set of fractional odds to work from. It will then select the closest matching value from that set. For convenience, a set of standard odds, representing those most typically found in the UK, has been provided.
o.to_fractional('5/4', '6/4', '7/4', '2/1') # 6/4
o.to_fractional(Odds.STANDARD_FRACTIONALS) # 6/4
Comparisons can be made between Odds instances. It is possible to check if one Odds instance is shorter (<) or longer (>) than another, e.g.
Odds(2.5) < Odds.fractional(11, 4) # True
Odds.probability(50) > Odds(3) # False
There are properties to compare Odds instances to evens, and a convenience method for evens itself, e.g.
o.is_odds_against # True
o.is_odds_on # True
Odds.evens() == 2 # True
There are also operators to perform calculations with Odds instances, though this is more useful in some cases than others. For example, it is possible to calculate the combined odds of two 3/1 shots as follows:
Odds.fractional(3, 1) + Odds.fractional(3, 1) == Odds.evens # True
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pybet-0.1.0.tar.gz
.
File metadata
- Download URL: pybet-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7809e789c0976c881a7f0f9796c5e2eff6105e234b139e6c6959ea78da9622d2 |
|
MD5 | d367e7206edd1b62ab5a6b3fb69bffe7 |
|
BLAKE2b-256 | 8bb92f8e3af9c59b5e1eb11c8c1b1f5139d6dcd6ef84c607b1a8c020289a757e |
Provenance
File details
Details for the file pybet-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pybet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fde3fef905a1172d987ee65f7f85358657bcb7f6d2e555799e3fe7b4256b005f |
|
MD5 | 41d18749646808351446684b6dc09bfb |
|
BLAKE2b-256 | f4f66b66cf82fd94ffe09b58fde0d716870d374c0a58cf155f8ce81e390cdd3c |