Metadata-Version: 2.4
Name: teachersbettextbook
Version: 0.1.0
Summary: The open betting-math textbook: de-vig, +EV, arbitrage, and Kelly sizing as a pure Python/NumPy library.
Author: Alex Thornton
License: MIT License
        
        Copyright (c) 2026 Alex Thornton
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://teachersbet.com
Project-URL: Learn, https://teachersbet.com/learn/
Project-URL: Source, https://github.com/athornton1618/TeachersBet
Keywords: betting,kelly-criterion,arbitrage,de-vig,expected-value,sports-analytics,probability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Education
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# teachersbettextbook

The open betting-math textbook — the standard, teachable math behind sports-betting
analytics, as a small, dependency-light Python/NumPy library.

It is the open half of [Teacher's Bet](https://teachersbet.com): the same math the
site shows its work with, extracted so you can import it, read it, and check it
yourself. Every free lesson at **[teachersbet.com/learn](https://teachersbet.com/learn/)**
is built on these functions.

> **Not betting advice.** Every function is a calculation on the inputs you supply —
> not a prediction, pick, or direction to wager, and no guarantee of any outcome.
> For informational and educational use. You must be of legal age to gamble in your
> jurisdiction. Gamble responsibly — 1-800-GAMBLER.

## Install

```bash
pip install teachersbettextbook
```

## What's inside

| Module | What it does |
| --- | --- |
| `devig` | moneyline ↔ implied probability / net odds, the vig, and fair-probability recovery — proportional, power, and Shin methods |
| `kelly` | single-bet, fractional, and joint simultaneous Kelly sizing |
| `arb` | two-outcome arbitrage detection and the stake split, with execution-risk caveats |
| `simulate` | Monte Carlo of repeated fractional-Kelly bets |

See [`FORMULAS.md`](https://github.com/athornton1618/TeachersBet/blob/main/teachersbettextbook/FORMULAS.md)
for every equation, and the free guides at
[teachersbet.com/learn](https://teachersbet.com/learn/) for the plain-language lessons.

## Quick start

```python
import teachersbettextbook as tb

# De-vig a two-sided moneyline into fair probabilities
tb.devig(-150, 130, method="shin")      # -> (p_a, p_b), summing to 1

# The book's margin (vig) baked into that line
tb.overround(-150, 130)                 # -> ~0.03

# Fractional Kelly stake for a 55% edge at even money (half-Kelly is the default)
tb.fractional_kelly(p=0.55, b=1.0)       # -> 0.05  (half of the full 0.10)

# Is there an arb across these books? How do you split the stake?
tb.find_arbitrage([
    {"book": "A", "ml_a": 110, "ml_b": -105},
    {"book": "B", "ml_a": -102, "ml_b": 115},
], total_stake=1000)                     # -> best prices, is_arb, stakes, return
```

## Worked examples

Runnable, step-by-step walkthroughs live in
[`examples/`](https://github.com/athornton1618/TeachersBet/tree/main/teachersbettextbook/examples)
— one per topic, each printing the full calculation with labelled intermediate values:

```bash
python examples/devig_example.py       # strip the vig from a moneyline three ways
python examples/kelly_example.py       # f*, the growth curve, half-Kelly, joint sizing
python examples/arb_example.py         # detect a two-book arb and split the stake
python examples/simulate_example.py    # Monte Carlo a season of fractional-Kelly bets
python examples/utils_example.py       # moneyline ↔ probability / odds, vig, Kelly ratio
```

## Tests

Every module has a comprehensive suite (known values, edge cases, and mathematical
invariants) under [`tests/`](https://github.com/athornton1618/TeachersBet/tree/main/teachersbettextbook/tests):

```bash
pip install teachersbettextbook[test]
pytest        # 160+ tests
```

## Scope

This package is **math only**. It contains no web app, no odds-data feeds, no
account or billing code, and none of the hosted service's proprietary
sharp-consensus anchor detection. It reads and runs on its own, offline.

## License

MIT. Copyright (c) 2026 Alex Thornton.
