Skip to main content

Fantasy football power rankings for public ESPN leagues

Project description

version PyPI version

Power Ranker

A tool for scraping fantasy football stats from ESPN leagues, creating power rankings, collecting previous season standings, and publishing to a website.

Update 2019-11-06: version 2.1.0 now has playoff Monte Carlo simulations reimplemented

Update 2019-09-12: version 2.0.1 is now working with the newest v3 of ESPN api

Check out package

pip3 install power_ranker

OR

git clone https://github.com/rynecarbone/power_ranker
cd power_ranker
python3 setup.py install

Generate a Configuration File

Download a local copy of the default configuration file. Once you have the file, fill in your league name, league id, year, and week (that you want to make rankings for). You can also adjust any of the settings that control the algorithms in the power rankings, or use the default values. For detailed instructions, see the Configuration File Documentation

To download a local copy of the configuration file, use the -dc (--download-config) option. If you are in a private league, use the -p (--private-league) option to log into your ESPN account and retreive cookie information:

power_ranker -dc 
Creating copy of: /Path/To/power_ranker/docs/default_config.cfg
To local destination: /Path/To/Current/Dir/MY_LOCAL_CONFIG.cfg

or

power_ranker -dc -p
Creating copy of: /Path/To/power_ranker/docs/default_config.cfg
To local destination: /Path/To/Current/Dir/MY_LOCAL_CONFIG.cfg
Username: <Enter ESPN Login>
Password: <Enter ESPN Password>

Use your favorite editor to open the local "MY_LOCAL_CONFIG.cfg" file and edit it.

Command line

After you have added your league information, pass the configuration file as an argument with the -c (--config-file) option. If you haven't already, you can add the -p (--private-league) option to log into your ESPN account and retreive cookie information.

power_ranker -c MY_LOCAL_CONFIG.cfg 
Using MY_LOCAL_CONFIG.cfg to generate power rankings

Week 3 Power Rankings
...

Alternatively, pass the league id, year, and week as command line arguments (-l --leagueid, -y --year, -w --week) and all other default power ranking settings will be used. Pass the -p option if in a private league.

power_ranker -l 123456 -y 2019 -w 1 
Using user input:
League ID: 123456
Year: 2019
Week: 1
Creating copy of: /Path/To/power_ranker/docs/default_config.cfg
To local destination: /Path/To/Current/Dir/MY_LOCAL_CONFIG.cfg

Week 1 Power Rankings 
...

After you run the rankings, a template website will be generated in a directory titled "output/". Follow the instructions on how to Publish Power Rankings to a Website if you want to share the output with your league. To add your own summary to the week's power rankings, edit the file "output/2017/power.html". Find the commented out section:

<!--- <p>FIXME! FIXME!
         Add your own commentary here! New write-up here!
         Or just leave the rankings</p> -->

Remove the <!-- and --> comment delimeters, and edit the text inside the paragraph markers (<p>, </p>).

Playoff Odds

See Configuration File Documentation for detailed instructins on how to alter the configuration file to run simulated playoff odds. You can control the number of simulations to run, where each simulation uses this season's scores to predict the outcomes of the remaining games. The fraction of simulations in which a team makes the playoffs determines that team's estimated odds of making the playoffs.

League History

The first time you run power_ranker, make sure 'do_Setup' option is set to True. It will search for and scrape stats for all previous seasons. A League history page will be created displaying the standings and stats from each of these past seasons.

Example Output

After successfully running the code, the generated website files should appear like the examples below:

Credit

The code to extract league info from hidden ESPN API, including retreiving league settings and accessing private league data, is largely thanks to Rich Barton's espnff package: https://github.com/rbarton65/espnff.

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

power_ranker-2.1.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

power_ranker-2.1.0-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file power_ranker-2.1.0.tar.gz.

File metadata

  • Download URL: power_ranker-2.1.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.1

File hashes

Hashes for power_ranker-2.1.0.tar.gz
Algorithm Hash digest
SHA256 4fa2682e788857daedef401d20432ce0da8d56736196cde1236f5fbf05b4b7b2
MD5 e8e87416c4cb54a145e7bc6dec1f701f
BLAKE2b-256 a902463db4d9e60c836f97d81b1087a282c1d090fea19c2bc5c64a8d5370851c

See more details on using hashes here.

File details

Details for the file power_ranker-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: power_ranker-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.1

File hashes

Hashes for power_ranker-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48439dee81884754e487778739fe0181f529294bfdfb9f6f52d778e34dfb80df
MD5 ceae5a35f6c97ce297ab158a93cd8174
BLAKE2b-256 ebeacbf901e95d9f5fa42caab401d0b9b587177c863597cc805f3669db2d158d

See more details on using hashes here.

Supported by

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