Open Source
The math is free — not as a slogan, as a package. Install it, read it, run it against your own numbers, and check every figure this site prints.
teachersbettextbook is an MIT-licensed Python library that implements the sports-betting mathematics behind Teacher’s Bet: American-moneyline conversions, three de-vig methods, expected value, single and simultaneous Kelly sizing, two-outcome arbitrage, Monte Carlo simulation, and Kalshi event-contract fee math. It is published on PyPI, has no web or data-feed dependencies, and runs offline.
Install it
pip install teachersbettextbook
One dependency (NumPy), Python 3.9 or newer, current version 0.2.0. No account, no key, no telemetry, nothing phones home.
Five lines that reproduce a number from this site
The expected value calculator ships with the market −140 / +120 and a price of +145 on the underdog. Here is that exact answer, computed locally — five lines and a print:
import teachersbettextbook as tb
p_a, p_b = tb.devig(-140, 120, method="power") # fair probabilities, margin removed
b = tb.moneyline_to_odds(145) # +145 -> $1.45 profit per $1 risked
ev = p_b * b - (1 - p_b) # expected value per $1 staked
stake = tb.fractional_kelly(p_b, b) * 1000 # half-Kelly on a $1,000 bankroll
print(f"fair {p_b:.4%} EV {ev:+.4%} stake ${stake:,.2f}")
# fair 43.4435% EV +6.4366% stake $22.20
Those are the same digits the calculator prints and the same digits the API returns, because all three run the same arithmetic. If the numbers ever disagree, the site is wrong and you can prove it in five lines.
The honest zero, in code
>>> tb.kelly_fraction(0.40, 1.45) # a 40% chance at +145 is below fair -0.013793103448275834 >>> tb.fractional_kelly(0.40, 1.45) # so the stake is clamped at zero 0.0
What is inside
| Module | What it computes |
|---|---|
devig | Moneyline ↔ implied probability and net odds, the overround, and fair-probability recovery three ways: proportional, power, and Shin. Also prob_to_decimal and prob_to_moneyline for the trip back. |
kelly | Full-Kelly fraction, fractional Kelly (half by default), the expected log-growth curve, and joint simultaneous Kelly across a slate of bets that settle together. |
arb | Best-price selection across books, the inverse-odds sum, the stake split that equalizes payouts, and the execution-risk warnings that come with it. |
simulate | Monte Carlo over repeated fractional-Kelly betting: bankroll paths, ruin frequency, and the distribution of ending bankrolls. |
kalshi | Kalshi event-contract fees: taker and maker fee with the exchange’s round-up-to-the-cent rule, fee-adjusted break-even, fee as a share of outlay, and round trip vs. hold-to-settlement. |
Every equation in all five modules is written out symbol by symbol on the formula sheet, with units and a worked number. The package ships the same list as FORMULAS.md.
The license
MIT. Copyright © 2026 Alex Thornton. Use it commercially, fork it, vendor it into a competing product, ship it inside something closed — the license asks for a copyright notice and nothing else. There is no non-commercial clause, no attribution-in-your-UI clause, and no field-of-use restriction.
The grant is irrevocable for every version already published. Nothing on this page is a promise about future releases beyond what the MIT text already gives you.
Where the code is
- PyPI — pypi.org/project/teachersbettextbook. The canonical distribution.
- The source ships inside the distribution itself.
pip download teachersbettextbook --no-binary :all:gets you the sdist: every module, the test suite,FORMULAS.md, the runnable examples, andLICENSE. Nothing is compiled and nothing is minified. - A public Git mirror is not up yet. The repository is private while the owning entity is being formed, so there is deliberately no repo link here rather than a link that 404s. When it opens, it will be listed in this section and in the package metadata.
Read it without installing it
pip download teachersbettextbook --no-binary :all: --no-deps -d ./tb tar -xzf ./tb/teachersbettextbook-*.tar.gz -C ./tb ls ./tb/teachersbettextbook-*/src/teachersbettextbook/ # __init__.py arb.py devig.py kalshi.py kelly.py simulate.py
FORMULAS.md in the same archive. That is the entire mathematical claim of this site, and it is short enough to read in one sitting.Tests, and why they are the interesting part
The suite covers known values, edge cases, and mathematical invariants — de-vigged probabilities summing to exactly 1, Kelly returning zero rather than a negative stake, the arbitrage split paying identically on both outcomes:
pip install "teachersbettextbook[test]" pytest
Separately, the site’s edge runtime is JavaScript, not Python. That mirror is held to the Python implementation by golden-value tests: a fixed set of inputs, the Python outputs recorded to full precision, and a failing build if the JavaScript reproduces anything different. Parity is enforced by value, not by matching function names — the names differ between the two mirrors and always have.
What is deliberately not in here
This is the open half of the product, and the boundary is drawn on purpose rather than by neglect. Not included, and not planned:
- The sharp-consensus anchor. How many venues qualify, how their prices are pooled in log-odds, how disagreement collapses into a confidence read, and when the board refuses to publish a consensus at all.
- The calibration ledger. The fitted per-venue weights — every venue’s closing price logged, scored against settled outcomes, and reweighted by measured accuracy. This improves with every settled market and is the one asset here that compounds.
- Correlation structure. How linked venues get discounted so a pool does not count one opinion twice.
- Feeds, accounts, billing, and the board. None of the service is in the package; it is math and only math.
What gets published is the result — the fair line, the confidence, the venue count, the timestamps — and never the internals that produced it. The redaction is enforced server-side, not in the browser. Methodology is the full account of what is and is not disclosed.
The dividing line is simple: textbook mathematics is open; fitted parameters are not. Every equation on the formula sheet is in the package. Nothing that was learned from market data is.
Why open it at all
Because the pitch is “you can check our math,” and that is an empty sentence if the math is a binary. Every competitor in this category is a black box; a de-vig you can read, run, and disagree with is the difference between a claim and an argument. A published, testable implementation also makes the site falsifiable in exactly the way an analytics tool should be.
It also means nothing here depends on trusting this site. If Teacher’s Bet went dark tomorrow, the arithmetic would still install.