Math SDK
Pure betting math with no network calls. Python and JavaScript share the same formulas and field names as the API: decimal, american, probability, ev_pct.
Core functions return full precision for model builders. Round only when you serialize an API-shaped response via serialize (ev_pct 4 dp, american int-rounded, probabilities 6 dp).
Worked Example
Fair probability 25% at decimal 4.5 is +12.5% EV. American +150 is decimal 2.5.
Python
from kashrock_math import ev_pct from kashrock_math.odds import american_to_decimal from kashrock_math.devig import multiplicative # Full precision (no rounding inside math) assert ev_pct(0.25, 4.5) == 12.5 assert american_to_decimal(150) == 2.5 print(multiplicative([1.91, 1.91])) # ≈ [0.5, 0.5] # API serialization only — match served responses from kashrock_math.serialize import round_ev_pct, round_american round_ev_pct(ev_pct(0.52, 1.91)) # 4 dp
JavaScript
import { evPct, odds, devig, serialize } from "@kashrock/math"
console.log(evPct(0.25, 4.5)) // 12.5
console.log(odds.americanToDecimal(150)) // 2.5
console.log(devig.multiplicative([1.91, 1.91]))
serialize.roundEvPct(evPct(0.52, 1.91)) // API 4 dp
Modules
- odds — American, decimal, fractional, cents, Hong Kong, Malay, Indonesian, implied probability
- devig — multiplicative, additive, power, Shin, worst-case (2-way and n-way)
- value — ev_pct, edge, break-even, ROI, CLV
- kelly — full, fractional, simultaneous
- parlay — independent and correlated
- dfs — multiplier to american, DFS EV
- arb / middle / hedge / exchange / fees — stake and venue math
- grade — push, void, quarter lines, overtime rules
- series — Bo1/3/5 from ordered per-map probs; correct score, map handicap, total maps
- rounds — per-side round rates, halftime switch, CS2/Valorant OT presets, rounds distribution
- props — Poisson/NegBin O/U; kills as per-round rate over rounds; map-scope sums
- rates — Beta-Binomial shrink, Wilson and Beta intervals; priors from line implied probability and long-run player rate (flat Beta(1,1) is demos only, not props default)
- elo — expected score and updates; optional K scaling from map score (2-0 vs 2-1, 3-0 vs 3-2)
- glicko — Glicko-1 rating-period update vs multiple opponents per period
- glicko2 — Glicko-2 period update with volatility
- bradleyTerry — pairwise win probability; MLE fit from (winner, loser) results with convergence settings
- calibration — Brier score, log loss, calibration buckets
- sampleSize — proportion SE, Wilson margin, sample size for target margin
- backtest — CLV aggregates plus ROI, units won, max drawdown, and bootstrap ROI interval when every row is settled
Install
Packages live in the monorepo as kashrock_math/ and kashrock_math_js/ (@kashrock/math). The API imports the same Python package so served numbers stay identical after serialize rounding.