Season Forecasting
Once the roster is staffed, the tool then forecasts the remainder of the season by simulating the stats for the remaining games. This is accomplished by weighting each player’s recent (7-day, 15-day, and 30-day) and season-long stats to project their stats for the rest of the season.
For certain statistics, these projections are a little more involved to calculate as they may involve certain metrics that aren’t provided by ESPN. Additionally, some pitchers throw significantly more or less innings, and some batters are on teams that where they get more or less at bats. Also, incorporating injuries into stat projections complicates things further. For example, does a pitcher have fewer innings thrown because they don’t go deep into games, or were they hurt for a month early in the season? The forecasting tool calculates trends for a player to solve this by normalizing certain stats or adjusting the short term / long term weights accordingly if they are outside an expected range.
Trade Simulations
To simulate a trade, the tool creates temporary rosters that would result after players are swapped. It then tries to optimize each roster based on a given stat category or across all stat categories. After creating optimal rosters, it simulates the remainder of the season using the techniques described above. With the season-ending statistics, it calculates the projected final standings to see how the trade would impact each team based on their previous projection before the trade.
As a command-line program, the final output is printed out in the terminal window. It shows the traded players, how each roster would change, how each stat category would shift, and the final standings projections. Printing these in a visually appealing way was a fun challenge. This output doesn’t use any 3rd party libraries, and I personally created all the text alignment, tables, and color changes. It also follows baseball rules and correctly color codes statistics that improve both by getting lower or higher. An example output is shown below.