Skip to main content

elo-system

An Elo rating system for fantasy sports leagues. It scrapes weekly scoreboards from a fantasy platform, converts them into per-week Elo ratings, and supports multi-season dynasty ratings with an offseason regression-to-mean adjustment.

  • Platforms: Fantrax (NBA, head-to-head categories) and Sleeper (NFL, head-to-head points). Sleeper needs its optional extra: pip install -e .[sleeper].
  • Scoring: football is rated against the league median by default (scoring: median), so a team's week stands or falls on its own score rather than on who it was scheduled against; scoring: default rates each matchup head to head on the two teams' share of the points instead.
  • Outputs: per-season and combined-dynasty rating frames, written to CSV or published to a Postgres star schema. Either backend can serve as the reader or the writer, and the two round-trip to the same frames. The schema keeps a person (dim_manager) separate from the accounts they play under (dim_manager_platform), so one manager can be in several leagues, on several Discord servers, across more than one platform.

Installation

The project depends on a fork of fantraxapi (the PyPI release is broken for H2H-rotisserie leagues), so it installs from source rather than from PyPI:

python -m venv .venv
source .venv/bin/activate
pip install -e .            # add [dev] for the test/lint tooling

requirements.frozen holds the exact, reproducible dependency pins (including the fantraxapi fork commit) used during development.

Layout

elo_system/
  elo_system.py            EloSystem orchestrator (config + reader/writer wiring)
  tools/
    elo_league.py          EloLeague: season management + run/dynasty pipeline
    elo_data.py            EloCSV / EloSQL persistence backends
    basics/                LeagueBase/DataBase, Elo math, config IO, constants
    helpers/               scraper, league, formatter, calculator, frame_manager

Configuration

resources/configs/ holds one shared config for each backend and one ratings config per league:

resources/configs/
  sys_config.yml           reader/writer, and the ratings config of each league
  csv_config.yml           shared: where CSV frames are written
  sql_config.yml           shared: the Postgres connection
  ratings_macho_mandarins.yml  one league
  ratings_die_nasty.yml      another

sys_config.yml names the leagues, and one EloSystem drives one of them:

ratings_configs:
  macho_mandarins: ratings_macho_mandarins.yml
  die_nasty: ratings_die_nasty.yml
default_league: macho_mandarins
EloSystem('resources/configs/sys_config.yml')                # default_league
EloSystem('resources/configs/sys_config.yml', 'die_nasty') # a named league

Each league's CSV frames go in their own subdirectory of the CSV config's write_loc, named for the league key, since the frames are named by season alone and would otherwise collide:

resources/ratings/
  macho_mandarins/2024_season_elo.csv  ...  dynasty_elo.csv
  die_nasty/2022_season_elo.csv  ...  dynasty_elo.csv

Override one league's subdirectory with ratings_dir in its ratings config.

Tests

python -m pytest          # run from the repo root

See CONTRIBUTING.md for development notes and conventions, and CHANGELOG.md for release history.

Metadata

Release files for elo-system 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elo-system 2.0.2
File Size Uploaded Provenance Actions
elo_system-2.0.2.tar.gz 109.8 kB Without provenance Details for elo_system-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for elo-system 2.0.2
File Interpreter ABI Platform Actions
elo_system-2.0.2-py3-none-any.whl Python 3 none any Details for elo_system-2.0.2-py3-none-any.whl

Total release size: 184.2 kB

Release files / elo_system-2.0.2.tar.gz

Download URL elo_system-2.0.2.tar.gz
Size 109.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5d8c1729a7cda7e01fe455eac6ce9de1e175aca46601c5a4356c8d844bdd5af
BLAKE2b-256 checksum
How to use checksums
22042cb2a15f0033a804e86eeb148c70ed58a5cf42c6c203cc89783a183eefc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / elo_system-2.0.2-py3-none-any.whl

Download URL elo_system-2.0.2-py3-none-any.whl
Size 74.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f19d4f279c304005b4cdc431474766d2e111739e59e80f3f57e0f7ca5d18be63
BLAKE2b-256 checksum
How to use checksums
a0b385c0a3f29d6e25d5463bef6d157950ee1a594b05ccf8bede64858a5c9085
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for elo-system 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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