You can calculate implied probabilities and proportional margin removal in Python without calling an odds API. Use Decimal values constructed from strings and require every outcome in the same complete market.
The example below uses illustrative decimal odds of 1.90 and 1.90. It reads no feed, places no bets and requires no credentials. The Python Decimal documentation explains the arithmetic model.
Run the example
Save this as odds_math.py and run python3 odds_math.py. A downloadable copy is available.
from decimal import Decimal, getcontext
getcontext().prec = 28
prices = [Decimal("1.90"), Decimal("1.90")]
if any(not price.is_finite() or price <= 1 for price in prices):
raise ValueError("Use finite decimal odds greater than one")
implied = [Decimal(1) / price for price in prices]
total = sum(implied)
print(f"overround={(total - 1) * 100:.3f}%")
for probability in implied:
print(f"fair_probability={probability / total:.6f}")
Expected output:
overround=5.263%
fair_probability=0.500000
fair_probability=0.500000
The 5.263% is overround, not an observed bookmaker profit. Normalization allocates margin proportionally; it does not establish the true chance of an outcome.
Check identity before arithmetic
For a football regulation 1X2 market, provide home, draw and away prices from the same settlement definition. Do not mix extra-time and regulation markets, currencies, bid/ask sides, or a prediction token's NO price with a different sportsbook outcome.
Use the no-vig calculator to reproduce the example, then read removing bookmaker margin and comparing odds safely.
Add an API only when you need one
A production adapter must preserve native values and timestamps, reject unknown units, and surface missing or suspended outcomes. The local example deliberately stops at arithmetic. For the implemented private-pilot contract, start with the API documentation.
Questions
Does this script fetch live odds?
No. It calculates from the two illustrative input strings and makes no network requests.
Why use strings when constructing Decimal?
String inputs preserve the written decimal value instead of first converting it through a binary float.
Is proportional normalization the only de-vig method?
No. Different allocation assumptions can produce different estimates, especially when prices are asymmetric.
Can I use just two football 1X2 outcomes?
No. Regulation 1X2 requires home, draw and away from the same complete market.
Is this a betting or execution bot?
No. It performs arithmetic only and does not connect to an account or place an order.