Skip to main content
Breaking in 4.0.0
  • Integer id columns are decimal strings — Every id column of integers (id, *_id, game_pk, playerId, …) comes back as exact decimal strings on every surface — parsers, producers, loaders, HockeyTech analytics. Compare and join ids as strings; Number(row.game_id) for a safe number back. (changelog)
  • 400 / 422 raise InvalidParameterError — For every family (it was AssetFetchError), never retried; the message names host, path and status with a redacted excerpt of the body. (changelog)
  • Typed returns — generated row types for parsed: true — TypeScript only. A wrapper's raw payload resolves to unknown (was any); verified endpoints resolve to their row interfaces; the summary dispatchers to ParsedTables. Narrow or cast a raw payload. (changelog)
  • Wrapper failures raise NoDataError / AssetFetchError — Instead of raw axios errors. NoDataError = the fetch worked and there is nothing there (404, ESPN { code: 404 }); AssetFetchError = the fetch failed (403 / 429 / 5xx after retries, network). Retries follow DEFAULT_RETRY_STATUSES with backoff. (changelog)

Odds math

Not data functions

These utilities never fetch a provider payload by themselves — they transform, classify, configure or look things up. The data surface (every espn* / native wrapper and load* loader) is under ESPN Reference.

Implied probabilities, vig removal and market blends — ports of sdv-py wexp.market.

Exportkindmodule
prob_from_americanfunctionsrc/odds/math.ts
prob_from_decimalfunctionsrc/odds/math.ts
devig_multiplicativefunctionsrc/odds/math.ts
devig_shinfunctionsrc/odds/math.ts
spread_to_probfunctionsrc/odds/math.ts
logit_blendfunctionsrc/odds/math.ts
moneyline_pair_probfunctionsrc/odds/math.ts
oddsMathconstsrc/odds/math.ts
oddsErrorsconstsrc/odds/math.ts
OddsValueErrorclasssrc/odds/math.ts
OddsZeroDivisionErrorclasssrc/odds/math.ts
OddsOverflowErrorclasssrc/odds/math.ts
OddsRuntimeErrorclasssrc/odds/math.ts

src/odds/math.ts​

Market math (ports of sdv-py wexp.market): implied probability from a price, vig removal (multiplicative, Shin), spread -> probability, logit blending. Mounted on sdv.odds under the py names and camelCase aliases; the Python-named errors under sdv.odds.errors.

Mounted on: sdv.odds (snake_case name + camelCase alias).

prob_from_american​

Implied probability of an American price (-110 -> 0.5238).

export function prob_from_american(price: number): number

Example:

sdv.odds.prob_from_american(-110); // 0.5238…

prob_from_decimal​

Implied probability of a decimal price (1.91 -> 0.5236).

export function prob_from_decimal(price: number): number

devig_multiplicative​

Remove the vig by scaling the raw probabilities to sum to 1.

export function devig_multiplicative(p_raw: readonly number[]): number[]

devig_shin​

Remove the vig with Shin's insider-trading model (falls back to multiplicative at overround <= 0).

export function devig_shin(p_raw: readonly number[]): number[]

spread_to_prob​

Cover probability of a point spread under a normal margin with standard deviation sigma.

export function spread_to_prob(spread: number, sigma: number): number

logit_blend​

Blend two probabilities on the logit scale with weight weight_a on the first.

export function logit_blend(p_a: number, p_b: number, weight_a

moneyline_pair_prob​

The home win probability from a home / away moneyline pair after vig removal (multiplicative or shin).

export function moneyline_pair_prob( home_price: number, away_price: number, method: string

oddsMath​

The functions above as one object (what sdv.odds spreads in).

export const oddsMath =

oddsErrors​

The errors below keyed by their Python names (ValueError, …) — sdv.odds.errors.

export const oddsErrors

OddsValueError​

A bad price or probability (py ValueError).

export class OddsValueError extends SdvError

OddsZeroDivisionError​

A division by zero in the market math (py ZeroDivisionError).

export class OddsZeroDivisionError extends SdvError

OddsOverflowError​

An overflow in the market math (py OverflowError).

export class OddsOverflowError extends SdvError

OddsRuntimeError​

The Shin solver could not bracket a root (py RuntimeError).

export class OddsRuntimeError extends SdvError

Generated by tools/codegen/generate.mjs from tools/codegen/utilities.yaml — see How this library is built.