Guide

Remove bookmaker margin from closing lines in Python

Short answer: American odds convert to implied probabilities that sum to more than 1, because the book's margin sits inside them. Three common rules remove it: multiplicative, additive and power. On 31 NBA closing lines they differed by about 0.006 to 0.009 on average. SportsDataHQ's get_game_probabilities returns the multiplicative result as fair_prob.

This is a measurement guide for modelers. It treats a posted price as information about what a market believed, and it never turns that into stakes or advice on wagering.

From American odds to implied probability

American odds quote a price for each side. A negative number is the amount you would put up to win 100, and a positive number is what 100 would win. The implied probability is:

  • A negative price uses -odds / (-odds + 100).
  • A positive price uses 100 / (odds + 100).

A closing line of -165 for the home side and +138 for the away side gives 0.6226 and 0.4202. Those add to 1.0428. The extra 0.0428 is the overround, the book's margin, spread across both sides. A probability that sums to more than 1 is not a probability distribution yet, so any model comparison that uses raw implied numbers carries a bias of roughly half the margin on each side.

Three ways to remove the margin

Each method maps the implied probabilities to a set that sums to 1. They disagree about where the margin sat.

  • Multiplicative divides each probability by the sum. It assumes the margin is proportional to each side's probability, so favorites and longshots lose the same share.
  • Additive subtracts an equal amount from each side. It assumes the same absolute margin on every outcome. On a lopsided market it can push a longshot toward zero or below.
  • Power raises each probability to a power k, chosen so the results sum to 1. It takes proportionally more from longshots than from favorites, which is the usual pattern in markets with a favorite-longshot bias.

Here are all three in plain Python. The power method has no closed form for two sides, so the code finds k by bisection.

def implied(american):
    return 100 / (american + 100) if american > 0 else -american / (-american + 100)

def multiplicative(ps):
    s = sum(ps)
    return [p / s for p in ps]

def additive(ps):
    m = (sum(ps) - 1) / len(ps)
    return [p - m for p in ps]

def power(ps):
    lo, hi = 0.5, 5.0                      # find k with sum(p ** k) == 1
    for _ in range(80):
        k = (lo + hi) / 2
        if sum(p ** k for p in ps) > 1: lo = k
        else: hi = k
    return [p ** k for p in ps]

ps = [implied(-165), implied(138)]
print(round(sum(ps) - 1, 4), [round(x[0], 4) for x in (multiplicative(ps), additive(ps), power(ps))])
# 0.0428 [0.5971, 0.6012, 0.6034]

All three keep the favorite as the favorite. They put the home win at 0.597, 0.601 and 0.603 for this one book, a spread of 0.006. The ordering is stable: multiplicative gives the lowest favorite probability, power the highest.

One game, eight books

Game 401909453 (POR hosting MEM, December 5, 2026) has eight closing moneylines. The table shows each book's overround and the home probability under each rule. Book names are left out on purpose.

BookHome / awayOverroundMultiplicativeAdditivePower
1-165 / +1380.04280.59710.60120.6034
2-162 / +1420.03150.59940.60250.6041
3-165 / +1400.03930.59910.60300.6049
4-170 / +1420.04290.60380.60820.6105
5-162 / +1360.04200.59340.59730.5993
6-156 / +1330.03860.58680.59010.5918
7-153 / +1400.02140.59210.59400.5950
8-165 / +1400.03930.59910.60300.6049

Averaged across books, the multiplicative home probability is 0.596, the additive one 0.600 and the power one 0.602. The margin differs by book, from 2.1 to 4.3 points, which is why removing it book by book before averaging is better than averaging the raw prices and removing one margin at the end.

Compare with get_game_probabilities

get_game_probabilities does that work for you. For a game id it returns, for each market, avg_implied_prob (the average of the books' raw implied probabilities, margin included) and fair_prob (the margin-free version), plus books_used. The default snapshot_type is closing, each book's last pre-game price so far, and opening gives each book's first.

For the same game the call returned avg_implied_prob 0.619 and fair_prob 0.596 for the home side, from 8 books. Our multiplicative average above is 0.5963, which rounds to the returned 0.596. The API's method note says it removes the margin proportionally from each book's two prices, then averages, and the match confirms it.

This script repeats the comparison over a sample of games. It reads each book's closing moneylines from get_odds, applies the three rules and compares the means with the API.

import json, os, statistics as S, urllib.request

KEY = os.environ["DUNKAPI_API_KEY"]
def post(tool, body):
    req = urllib.request.Request("https://mcp.dunkapi.com/v1/" + tool, data=json.dumps(body).encode(),
          headers={"Content-Type": "application/json", "x-api-key": KEY})
    with urllib.request.urlopen(req, timeout=60) as r:
        return json.load(r)["data"]

def compare(game_id):
    game = post("get_odds", {"game_id": game_id})["games"][0]
    fair = post("get_game_probabilities", {"game_id": game_id})["moneyline"]
    out = {"multiplicative": [], "additive": [], "power": []}
    for b in game["books"]:
        if b["home_ml_close"] is None or b["away_ml_close"] is None:
            continue
        ps = [implied(b["home_ml_close"]), implied(b["away_ml_close"])]
        out["multiplicative"].append(multiplicative(ps)[0])
        out["additive"].append(additive(ps)[0])
        out["power"].append(power(ps)[0])
    return fair["home"]["fair_prob"], {k: round(S.mean(v), 4) for k, v in out.items()}

print(compare("401909453"))
# (0.596, {'multiplicative': 0.5963, 'additive': 0.5999, 'power': 0.6017})

On 31 completed NBA games drawn at random from this season's regular schedule, the mean absolute difference from the API's fair_prob was:

MethodMean absolute gapLargest gap
Multiplicative0.00030.0005
Additive0.00560.0155
Power0.00860.0248

The multiplicative gap is rounding: fair_prob is returned to three decimals. The mean overround across those games was 0.040. In every game the number of books we used equaled the API's books_used.

Where the methods part ways

The gap grows with how lopsided the market is. The most one-sided game in the sample had a returned fair probability of 0.843 for the home side. Multiplicative gave 0.8435, additive 0.8583 and power 0.8673, spreads of 0.015 and 0.024. A constructed extreme shows the mechanism. Take a price pair of -5000 and +1500, with an overround of 0.043. The longshot's fair probability is 0.060 multiplicatively, 0.041 additively and 0.026 by the power rule. A model scored with log loss can swing noticeably on that difference when a game's outcome goes the unlikely way, and an additive rule can produce a negative probability at more extreme prices.

Which rule is right is not settled by the prices. The tests that settle it use outcomes: score each rule's probabilities with log loss or Brier score over many games and see which is better calibrated. Even then, the answer can differ by league and price range.

Limits

  • Two-way and three-way markets only. The code handles two outcomes. A three-way soccer line has a draw, and the same three rules extend to three sides. The additive rule subtracts a third of the margin from each.
  • The API reports one rule. fair_prob is the multiplicative one. If you want additive or power numbers, compute them from get_odds, which carries each book's closing moneylines.
  • Rounding. Probabilities are returned to three decimals. Do not compare methods at a precision finer than that.
  • Closing means last capture. In the NBA, the closing line is usually a few minutes before the listed start. A line first read after the start has captured_at null and is treated as a closing-line record. See the data timing page for what each timestamp means.
  • Not advice. A fair probability describes the market. It is not a prediction of the result, and nothing here is a recommendation to wager.

Get a free key Or download whole seasons as Parquet

Checked against the live API on 2026-12-06. Questions: hello@sportsdatahq.com.