Skip to main content

Automate playing Yahoo Fantasy Football

Project description

fantasy-football-bot (ffbot)

PyPI Latest Release PyPI downloads License Code style: black Imports: isort codecov

Automate playing Yahoo Fantasy Football

Installation

pip install ffbot

Usage

>>> import ffbot

Scrape player forecasts

To connect to your Yahoo league and team, you need your league ID and team ID. Visit your team at https://football.fantasysports.yahoo.com/f1/, and the url will also include your league and team ID.

>>> LEAGUE = 123456
>>> TEAM = 1
>>> POSITIONS = "QB, WR, WR, WR, RB, RB, TE, W/R/T, K, DEF, BN, BN, BN, BN, IR"
>>> week = ffbot.current_week()
>>> df = ffbot.scrape(LEAGUE)
>>> # If playing an Individual Defensive Player (IDP) league, then scrape additional players with:
>>> # df = ffbot.scrape(LEAGUE, is_IDP=True)
Scraping all QB...
Scraping all WR...
Scraping all RB...
Scraping all TE...
Scraping all K...
Scraping all DEF...
Scraping weekly forecasts...
Total runtime: 0:10:33.784455

Optional methods to save data to CSV, and load data:

>>> ffbot.save(df, week)
>>> df, week = ffbot.load()  # loads latest file, but you can also provide a filepath

Optimize add and drop players

ffbot.optimize() is used to find players to add and drop that maximize your team's performance. The optimizer decides which players to add and drop, and how to assign each player to positions each week. Optimization is repeated for current roster, for one player add/drop, two player add/drops, etc.

>>> df_opt = ffbot.optimize(df, week, TEAM, POSITIONS)
>>> print(df_opt)
                              Add              Drop Total points Discounted points     VOR
0                <current roster>                        1583.94            367.51  226.73
1                     Kansas City                          16.27              2.24   -7.98
2                     Matt Bryant         Joey Slye          4.6              1.67   -3.63
3                  Dede Westbrook      Kenyan Drake         4.27              0.65    2.75
4 Jordan Howard - Waivers (Oct 2)  Marvin Jones Jr.        10.37             17.23   -3.54

which means that optimal weekly rosters of your current players scores 1583.94 points across the season and 367.51 discounted points (points in week 1 are worth more than week 12). The best free agent to add is Kansas City, which increases discounted points by 2.24 (although lowers total season points by 16.27 and lowers value over replacement by 7.98). Two other free agent pickups improve discounted points. Only one Waiver claim (for Jordon Howard) increases discounted points.

Contribution

Please add Issues or submit Pull Requests!

For local development, install optional testing dependencies and pre-commit hooks using

pip install ffbot[test]
pre-commit install

Project details


Download files

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

Source Distribution

ffbot-1.2.11.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

ffbot-1.2.11-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file ffbot-1.2.11.tar.gz.

File metadata

  • Download URL: ffbot-1.2.11.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ffbot-1.2.11.tar.gz
Algorithm Hash digest
SHA256 e04a1026f6d93c97d0bfb1d1e96b8e06c9340bbb42182c11286f03c186dac25c
MD5 4b4d4a0f6e9d38960a14c38b3aae3f25
BLAKE2b-256 e01468418ebd2f8be08f2b5dc2f1405dfe66d8a5e8f60a9f1cb298107bcf187e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffbot-1.2.11.tar.gz:

Publisher: python-publish.yml on amarvin/fantasy-football-bot

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

File details

Details for the file ffbot-1.2.11-py3-none-any.whl.

File metadata

  • Download URL: ffbot-1.2.11-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ffbot-1.2.11-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd57ddc0575c58d388ee16747bf51feb91e11acbd550a69e70ec556c56c85a7
MD5 69aba858b00cefa60d380187043e4fa4
BLAKE2b-256 7a44048b439c2d8f8fd35cc5c2530e9fc95fb0388483167ac5610d5b832bcf56

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffbot-1.2.11-py3-none-any.whl:

Publisher: python-publish.yml on amarvin/fantasy-football-bot

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page