Open Source
The math is free. Not as a slogan, as a package you can install and run against your own numbers.
teachersbettextbook is an MIT-licensed Python library holding the arithmetic behind
Teacher's Bet: moneyline conversions, three de-vig methods, expected value, Kelly sizing, arbitrage,
Monte Carlo, and Kalshi fee math. It is on PyPI, it has no feed or web dependency, and it runs
offline.
Install it
pip install teachersbettextbook
One dependency (NumPy), Python 3.9 or newer, currently 0.4.0. No account, no key, no telemetry. Nothing phones home.
Five lines that reproduce a number off this site
The expected value calculator opens on the market −140 / +120 with a price of +145 on the underdog. Here is that exact answer, computed on your own machine:
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
Same digits as the calculator and the API, because all three run the same arithmetic. If they ever disagree, we are 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. |
odds | One price written in every notation: American, decimal, fractional, percent and prediction-market cents, with the fractional form reduced exactly by continued-fraction convergents. Plus payout: profit, total return, and the vig-free payout beside the posted one. |
middle | Two opposite-side prices at different numbers: the combined implied probability, the hit rate the window has to land, the equal-payout stakes, and the three-cell payoff grid. It keeps the required rate and the hold apart, because they are different numbers. |
hedge | Hedge sizing on a bet already placed, including the stake that pays the same either way (it divides the first bet’s total return, not its profit), and what buying the certainty costs in expected value once both current prices are de-vigged. |
teaser | The per-leg win rate a quoted teaser price needs, what the bought points have to add in probability, the payout given up against the same legs parlayed straight, and the comparison against buying those numbers straight. |
roundrobin | Every combination of a set of legs as its own parlay: the ticket count, the total risk (the stake is per ticket), and an exact hit-level table from enumerating all 2n outcomes rather than sampling them. |
breakeven | The win rate a price needs, with the exchange fee where there is one, and the statistics that say whether a settled record has separated from it: a proportion test, a Wilson score interval, and the sample size an edge of that size needs. |
Every equation in all eleven 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 licence
MIT. Copyright © 2026 Escapement Technologies LLC. Use it commercially, fork it, vendor it into something that competes with us, ship it inside something closed. It asks for a copyright notice and nothing else. No non-commercial clause, no attribution-in-your-UI clause, no field-of-use restriction.
The grant is irrevocable for every version already published. Nothing here promises anything about future releases beyond what the MIT text already gives you.
One wrinkle, stated rather than glossed over: the notice changed hands partway through. 0.4.0 and later say Copyright (c) 2026 Escapement Technologies LLC. 0.3.0 and earlier went out before the company existed and say Copyright (c) 2026 Alex Thornton, which is not retroactively editable and has not been edited. The permissions are identical. The notice you have to keep is whichever one shipped in the version you actually took.
Where the code is
- PyPI: pypi.org/project/teachersbettextbook. The canonical distribution.
- The source ships inside it.
pip download teachersbettextbook --no-binary :all:gets you every module, the tests,FORMULAS.md, the examples andLICENSE. Nothing compiled, nothing minified. - No public Git mirror yet. The repo is private while the entity settles, so there is deliberately no link here rather than one that 404s. It will be listed here when it opens.
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 breakeven.py devig.py hedge.py kalshi.py # kelly.py middle.py odds.py roundrobin.py simulate.py teaser.py
FORMULAS.md. That is the entire mathematical claim of this site, and it is short enough to
read in one sitting.The tests are the interesting part
Known values, edge cases, and the invariants that actually matter: de-vigged probabilities summing to exactly 1, Kelly returning zero instead of a negative stake, an arbitrage split paying the same on both outcomes.
pip install "teachersbettextbook[test]" pytest
The site's edge runtime is JavaScript, not Python. That mirror is held to the Python one by golden tests: fixed inputs, the Python answers recorded to full precision, and a failing build if the JavaScript produces anything else. Parity is enforced by value. The function names differ between the two and always have.
What is deliberately not in here
This is the open half, and the line is drawn on purpose. Not included, not planned:
- The sharp-consensus anchor. How many venues qualify, how prices pool in log-odds, how disagreement becomes a confidence read, and the point at which a consensus is refused.
- The calibration ledger. Fitted per-venue weights: every venue's closing price logged, scored against what actually settled, reweighted by measured accuracy. It improves with every settled market and it is the one thing here that compounds.
- Correlation structure. How linked venues get discounted so a pool does not count one opinion twice.
- Feeds, accounts, billing, the board. None of the service is in the package. It is math and only math.
We publish the result (fair line, confidence, venue count, timestamps) and never the internals behind it, and the redaction is enforced on the server, not in your browser. Methodology is the full account.
The dividing line is simple: textbook math is open, fitted parameters are not. Every equation on the formula sheet is in the package. Nothing learned from market data is.
Why open it at all
Because "you can check our math" is an empty sentence if the math is a binary. Everyone else 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.
It also means none of this depends on trusting us. If the site went dark tomorrow, the arithmetic would still install.