Skip to main content
fantasyfb logo

fantasyfb

Fantasy football league simulation and optimization toolkit. Pulls projections from nflverse data, syncs roster state from a Yahoo Fantasy league, and runs Monte Carlo season simulations to value pickups, trades, and draft picks.

PyPI version Run Tests License: MIT

Docs: https://tefirman.github.io/fantasyfb/

Install

pip install fantasyfb

For local development:

git clone https://github.com/tefirman/fantasyfb.git
cd fantasyfb
pip install -e ".[dev]"

Python 3.10+ is required.

Quickstart

import fantasyfb as fb

league = fb.League(name="My Team")
schedule_sim, standings_sim = league.season_sims(postseason=True)
print(standings_sim[["team", "wins_avg", "playoffs", "winner"]])

fb.League(name=...) reads from the Yahoo Fantasy API, so you'll need oauth2.json (and .env with CONSUMER_KEY / CONSUMER_SECRET) set up alongside the script. See the yahoo_oauth docs for a walkthrough.

Command-line tools

After install, four entry points are on your PATH:

Command Source Use
fantasyfb fantasyfb.league:main Weekly projections + lineup analysis
snake-draft fantasyfb.drafts.snake:main Live snake-draft cockpit
salary-cap-draft fantasyfb.drafts.salary_cap:main Live salary-cap (auction) draft tool
draft-prep fantasyfb.drafts.prep:main Pre-draft tiers / VORP / mocks
# Weekly run for a team
fantasyfb --team "My Team" --sims 1000 --adds --drops

# Pre-draft analytics
draft-prep tiers --team "My Team"
draft-prep mock --team "My Team" --adp ADP.csv --my-pick 7 --sims 50

# Draft-day cockpit
snake-draft --team "My Team" --adp ADP.csv
salary-cap-draft --team "My Team"

Run any command with --help for the full option list.

NFL data (stats, schedules, rosters) is cached to disk for 24 hours, so repeated runs within that window work offline. Past the 24h mark you'll need a live connection again to refresh the cache — see nflreadpy caching for details and the --refresh-cache flag.

Public API

from fantasyfb import (
    League,                            # main entry point
    FantasyScorer,                     # scoring rules -> points
    MatchupModel, ProjectionEngineV2,  # projection internals
    LineupOptimizer,
    SeasonSimulator, ScheduleManager,
    NflreadpyProvider,                 # default data backend
)

Lower-level utilities live in submodules and can be imported directly:

from fantasyfb.drafts.tools import compute_vorp, assign_tiers, MockDraft
from fantasyfb.drafts.snake_cockpit import build_board, view_best
from fantasyfb.sim.backtest import run_backtest, evaluate
from fantasyfb.io.excel_exporter import FantasyExcelExporter
Subpackage Purpose
fantasyfb.league Top-level League class
fantasyfb.configs League / scoring presets
fantasyfb.drafts Snake, salary-cap, prep, shared draft math
fantasyfb.data Yahoo client + nflverse providers
fantasyfb.scoring Scoring, lineup optimization, matchups
fantasyfb.projections V2 projection engine, walk-forward fitter
fantasyfb.sim Season simulation, backtests, schedule
fantasyfb.analysis WAR, move analysis
fantasyfb.io Excel export

Development

pip install -e ".[dev]"
pytest                       # full test suite
python -m build              # produce sdist + wheel under dist/

The tests/ directory pulls a small slice of nflverse parquet data on first run; subsequent runs are cached locally.

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fantasyfb-0.8.2.tar.gz (196.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fantasyfb-0.8.2-py3-none-any.whl (144.8 kB view details)

Uploaded Python 3

File details

Details for the file fantasyfb-0.8.2.tar.gz.

File metadata

  • Download URL: fantasyfb-0.8.2.tar.gz
  • Upload date:
  • Size: 196.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fantasyfb-0.8.2.tar.gz
Algorithm Hash digest
SHA256 8c44d502ee09d12429192926fda2c797c5a0c05e115884f8ceb6f3414e2426d3
MD5 c50ab6c189ddfcb7c639d0afd64a5eb1
BLAKE2b-256 c456f000e4d5f8f89753ab02f1956b7b1f77b95d7dd3310405780ee13a933efd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fantasyfb-0.8.2.tar.gz:

Publisher: publish.yml on tefirman/fantasyfb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fantasyfb-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: fantasyfb-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 144.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fantasyfb-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d58b4321a0d82cb47126aed133a471104a71d4db754a206554fed0c98ad90b1
MD5 7c5699a0f47e63c3e826e56d4ceb4a6f
BLAKE2b-256 5d57129b9361145f06aaa2ec0c1d44ecc72d0ca882aa1e979db9e24241897ec0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fantasyfb-0.8.2-py3-none-any.whl:

Publisher: publish.yml on tefirman/fantasyfb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page