These scripts help value and rank players in ESPN and Yahoo fantasy baseball head to head categories league. League settings are configurable, including the categories.
See the introduction for details on the valuation model.
The category valuations are applied against rest-of-season projections from Fangraphs to calculate a cumulative winning probability added for the players.
Fangraphs has changed their form data in the past. Verify that the existing form data works for the current season.
- Fangraphs form data should be saved as
config/projections.viewstate
andconfig/leaderboard.viewstate
. - Note: if updating this form data is too time-consuming, just save response data into the projections directory.
- Update
config.json
in Yahoo league data directory.
- Update
config.json
in ESPN league data directory. - Update configuration file by making a copy of
config.py.sample
, renaming toconfig.py
, and filling out the configuration.- Update:
CURRENT_YEAR
season_final_day
BATTER_BUDGET_RATIO
- Traditionally, this is set to around 0.66 (i.e. 33% to pitchers)
- In 2018, the actual ratio was 0.68
- Update:
scrape_fangraphs.py --draft
- Scrape the pre-season projections from Fangraphs. The projection system used is configurable.
- Update player information in each league.
- ESPN: Call
save_eligibilities
method after instantiating ESPN league.
- ESPN: Call
map_players.py
- TODO: update this script
- Update keepers list under
data/keepers.csv
. python batter_valuation.py --draft
python pitcher_valuation.py --draft
To gather fresh data:
scrape_playing_time.py
- Scrape the number of PA / IP for each player in the past 14 days.
scrape_fangraphs.py
- Scrape the rest-of-season projections from Fangraphs. The projection system used is configurable.
map_players.py
- Each data source uses different names and ids for players. This creates a mapping table that translates between different ids from different systems.
In general, we want to update league specific information and valuations next.
- Update rosters.
- We want to have current rosters for each team, and positional eligiblities to make positional adjustments for players. This is different for each league, so we store this in a league-specific data directory.
- Scrape the most recent scores.
- After each scoring period, we'll have additional information on the relative value of each category. (For example, if SB have been low this season, the value of an individual SB will likely increase.)
- Update the category valuations.
- Update player valuations.
- For Yahoo leagues, to update positional eligibility and team rosters:
yahoo = Yahoo("example_league_data_directory") yahoo.refresh_rosters() yahoo.refresh_eligibilities()
- Call
refresh_scores
with the week number you want scores for.yahoo.refresh_scores(week_number)
- Update category valuations.
- TODO: Implement this.
- Update player valuations.
yahoo.load_players() yahoo.output_valuations()
- For ESPN leagues, to update positional eligibility and team rosters:
espn = league.Espn("example_league_data_directory") espn.save_eligibilities()
- Call
save_scores
which will save all scores up to the current week.espn.save_scores()
prob_added.py
- Update the logistic regression.
- Update player valuations.
batter_valuation.py
pitcher_valuation.py