The odds you get from any odds API include the bookmaker's margin, so raw implied probabilities add up to more than 100%. To get true probabilities you need to de-vig the market: convert odds to implied probabilities, measure the overround, then normalize. This guide gives you working Python for three methods, a multi-bookmaker consensus, closing-line value and a test suite, all in about 60 lines.
If you build anything on odds data (a model, a dashboard, a trading tool, a backtest), you will hit this problem on day one. A market quoted at 1.91 / 3.40 / 4.20 looks like it says the home side wins 52.4% of the time. It doesn't. That number is inflated, and every decision built on it inherits the error.
This tutorial fixes it, step by step.
Why Raw Implied Probability Is Wrong
Decimal odds convert to implied probability with one line: p = 1 / odds. But a bookmaker doesn't quote fair prices. They shave every price so the book totals more than 100%. That excess is the overround (also called margin, vig or vigorish), and it is the bookmaker's expected profit on balanced turnover. The mathematics of bookmaking is old and simple: a fair book sums to 100%, a quoted book to something higher.
Take a football 1X2 market:
Outcome Decimal odds Implied probability (1/odds)
Home 1.91 52.36%
Draw 3.40 29.41%
Away 4.20 23.81%
Total 105.58%
The overround is 5.58%. Those three percentages cannot all be true, because probabilities of mutually exclusive outcomes must sum to 100%. De-vigging removes the 5.58% in a principled way.
The Three De-Vig Methods (and When to Use Each)
There is no single "correct" way to split the margin. Each method makes a different assumption.
Method Assumption Best for Weakness
Proportional (multiplicative) Margin is spread in proportion to each price Quick, tight two-way markets Ignores favourite-longshot bias
Power Margin hits longshots harder 3+ outcome markets, longer odds Needs a numeric solve
Shin Margin reflects insider trading Research, long-shot-heavy markets More complex, rarely needed
The proportional method is described as sensible but a little ad hoc in Karl Whelan's explainer on the bookmaker's margin. The power method is a reasonable step up when longshots are involved, because raw prices tend to overstate longshots, a pattern known as favourite-longshot bias (covered in this overround reference entry).
Step 1: Implied Probability and Overround
Create devig.py:
python
def implied(odds: dict) -> dict:
"""Decimal odds -> raw implied probabilities."""
return {k: 1 / v for k, v in odds.items()}
def overround(odds: dict) -> float:
"""Bookmaker margin: sum of implied probabilities minus 1."""
return sum(implied(odds).values()) - 1
Test it with the market above:
python
odds = {"home": 1.91, "draw": 3.40, "away": 4.20}
print(f"Overround: {overround(odds):.2%}") # Overround: 5.58%
Step 2: Proportional De-Vig
Divide each implied probability by the total:
python
def proportional(odds: dict) -> dict:
q = implied(odds)
total = sum(q.values())
return {k: v / total for k, v in q.items()}
def fair_odds(probs: dict) -> dict:
return {k: 1 / p for k, p in probs.items()}
Result for our market:
Outcome Raw implied Fair probability Fair odds
Home 52.36% 49.59% 2.0165
Draw 29.41% 27.86% 3.5896
Away 23.81% 22.55% 4.4342
Total 105.58% 100.00%
Notice that "1.91" for the home side is not a 52.4% shot. The fair price is closer to 2.02.
Step 3: Power Method
The power method finds an exponent c so that the adjusted probabilities sum to exactly 1. Longshots get reduced more than favourites:
python
def power_method(odds: dict) -> dict:
q = implied(odds)
lo, hi = 1.0, 10.0
for _ in range(100): # bisection search for c
mid = (lo + hi) / 2
if sum(v ** mid for v in q.values()) > 1:
lo = mid
else:
hi = mid
c = (lo + hi) / 2
return {k: v ** c for k, v in q.items()}
For the same market, c ≈ 1.0553:
Outcome Proportional Power
Home 49.59% 50.52%
Draw 27.86% 27.49%
Away 22.55% 21.99%
The power method gives the favourite slightly more and the longshot slightly less. On a tight market the gap is small. On wide, longshot-heavy markets (outrights, horse racing fields) it matters.
Two-Way Markets Are Simpler
For totals or spreads quoted at 1.90 / 1.90, the overround is 5.26% (1/1.90 + 1/1.90 - 1), and the fair probability is 50% each, fair odds 2.00. With only two outcomes, the proportional and power methods give very similar answers, so use proportional and move on.
Step 4: Convert Other Odds Formats First
Odds APIs and bookmakers don't always return decimals. Convert before you de-vig:
python
def american_to_decimal(a: float) -> float:
return 1 + a / 100 if a > 0 else 1 + 100 / abs(a)
def fractional_to_decimal(num: float, den: float) -> float:
return 1 + num / den
print(american_to_decimal(-110)) # 1.909...
print(american_to_decimal(150)) # 2.5
print(fractional_to_decimal(6, 4)) # 2.5
A single-format pipeline avoids the most common bug in odds code: mixing formats in one calculation. If you need a quick refresher on the terms, the Orbistats glossary covers implied probability and the rest, and the tools page has odds converters.
Step 5: Build a Consensus Fair Price Across Bookmakers
One bookmaker's price is noisy. Averaging the de-vigged probabilities across several books gives a sturdier estimate. This is where a normalized odds feed saves real work, because you compare one schema instead of writing a parser per bookmaker. See our Sports Odds API Guide for how normalization works.
python
from statistics import mean
def consensus(books: list[dict], method=proportional) -> dict:
outcomes = books[0].keys()
fair = [method(b) for b in books]
return {o: mean(f[o] for f in fair) for o in outcomes}
books = [
{"home": 1.91, "draw": 3.40, "away": 4.20},
{"home": 1.95, "draw": 3.30, "away": 4.10},
{"home": 1.88, "draw": 3.50, "away": 4.30},
]
print(consensus(books))
{'home': 0.4954, 'draw': 0.2789, 'away': 0.2257}
De-vig each book first, then average. Averaging raw odds first and de-vigging afterwards mixes margins from different books and distorts the result.
Step 6: From Fair Probability to Edge
Once you have a fair probability and a model probability, expected value per unit staked is:
python
def expected_value(model_prob: float, decimal_odds: float) -> float:
return model_prob * decimal_odds - 1
print(f"{expected_value(0.55, 1.91):+.2%}") # +5.05%
If your model says the home side wins 55% of the time and the market offers 1.91, your edge is +5.05% per unit. A common sizing rule is the Kelly fraction:
python
def kelly(p: float, decimal_odds: float) -> float:
b = decimal_odds - 1
return max(0.0, (b * p - (1 - p)) / b)
print(f"{kelly(0.55, 1.91):.2%}") # 5.55% of bankroll at full Kelly
Full Kelly is aggressive and assumes your probability is exactly right. Most practitioners use a fraction of it. Treat all of this as analysis, not a promise of profit: odds data is information only and does not guarantee betting outcomes.
Step 7: Closing Line Value (CLV)
A strong sanity check for any model is whether you beat the closing price. Compare the odds you took with the de-vigged closing probability:
python
def clv(taken_odds: float, closing_odds: dict, outcome: str) -> float:
closing_fair = proportional(closing_odds)[outcome]
return taken_odds * closing_fair - 1
closing = {"home": 1.91, "draw": 3.40, "away": 4.20}
print(f"{clv(2.10, closing, 'home'):+.2%}") # +4.14%
Positive CLV over many bets means you consistently got better prices than the market's final consensus. To test that at scale you need historical opening and closing odds. Our guide on backtesting a sports betting model with historical odds data shows how to avoid lookahead bias, and the Historical Sports Data API is built for that archive work.
Plugging It Into an Odds API
The pattern is the same whichever provider you use: fetch a market, pull out the decimal odds for each outcome, and pass them to the functions above. A normalized market typically looks like this (always confirm field names in the API reference):
json
{
"market": "1X2",
"odds": { "home": 1.91, "draw": 3.40, "away": 4.20 }
}
python
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.orbistats.com/v1"
def fair_from_market(market: dict) -> dict:
return proportional(market["odds"])
Replace the endpoint below with the odds endpoint from the API reference
resp = requests.get(
f"{BASE}/",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=10,
)
resp.raise_for_status()
market = resp.json() -> adapt to the documented response shape
print(fair_from_market(market))
Authentication uses a Bearer token. The documentation, quickstart and sandbox show the exact endpoints, and the Orbistats Odds API page explains the markets covered.
Test It: Five Checks That Catch 90% of Bugs
python
import math
def test_probabilities_sum_to_one():
for m in (proportional, power_method):
p = m({"home": 1.91, "draw": 3.40, "away": 4.20})
assert math.isclose(sum(p.values()), 1.0, abs_tol=1e-9)
def test_two_way_even_market():
p = proportional({"over": 1.90, "under": 1.90})
assert math.isclose(p["over"], 0.5)
def test_overround_positive():
assert overround({"home": 1.91, "draw": 3.40, "away": 4.20}) > 0
def test_favourite_stays_favourite():
p = power_method({"home": 1.50, "away": 2.80})
assert p["home"] > p["away"]
def test_fair_odds_above_quoted():
odds = {"home": 1.91, "draw": 3.40, "away": 4.20}
fo = fair_odds(proportional(odds))
assert all(fo[k] > odds[k] for k in odds)
Run them with pytest. The last one is the key intuition: fair odds are always higher than the quoted odds, because the margin has been stripped out.
Common Pitfalls
Symptom Likely cause Fix
Probabilities sum to 1.05, not 1.00 You skipped de-vigging Normalize with proportional() or power_method()
Fair odds look wrong on one bookmaker Mixed formats (American + decimal) Convert everything to decimal first
Consensus is skewed Averaged raw odds before de-vigging De-vig each book, then average
Longshot probabilities look too high Proportional method on a wide market Use power_method()
ZeroDivisionError An outcome has odds of 0 or missing Filter out suspended or missing prices
Backtest looks too good Used closing odds as if they were available early Separate opening, in-play and closing snapshots
Margin changes between calls Live odds move constantly Timestamp every snapshot and compare like with like
When to Stream Instead of Poll
If you recompute fair prices on live markets, polling adds delay and wastes requests. For screens that must stay current, a persistent stream is a better fit than repeated requests. Orbistats offers both a WebSocket API and webhooks, and you can still keep REST for snapshots and history.
FAQ
What is the bookmaker margin?
The amount by which the implied probabilities of all outcomes sum to more than 100%. It represents the bookmaker's expected profit. Wikipedia's vigorish entry shows a worked NBA example.
What is the best de-vig method?
There isn't one. Proportional is fine for tight, two-way markets. Power is a better default for markets with longshots. Pick one, apply it consistently, and compare results.
Can I de-vig American odds directly?
Convert to decimal first, then apply the same formulas.
Is removing the vig the same as finding value?
No. De-vigging only gives you the market's fair estimate. Value comes from comparing that with your own, better probability.
How many bookmakers should I average?
More is steadier, but quality matters more than quantity. Sharper books deserve more weight in a serious model.
The Bottom Line
Raw odds are a price, not a probability. Strip the margin, compare across bookmakers, and measure yourself against the closing line, and you'll make better decisions than anyone reading the numbers at face value.
Want real odds to practice on? Request access and start with the free 1-hour plan, or see the pricing for longer windows. Questions? Email the team.
Examples are for education and analysis. Odds data is information only and does not guarantee betting outcomes or profit. Check local laws and data licensing terms before building a commercial product.
Top comments (0)