amarvin / fantasy-football-bot

Automate playing Yahoo Fantasy Football
MIT License
46 stars 9 forks source link

Idea - Trade Finder #20

Open Incogneat01234 opened 5 years ago

Incogneat01234 commented 5 years ago

Hey, saw your project here and have an idea for the most powerful yahoo tool you could possibly create - a trade finder which abuses the Yahoo trade eval screen.

Since you are already scraping weekly projection, you have all the info you already need. It also looks like you have a method for finding optimal lineups too. The rest is a fairly simple workflow.

1 - Have a user select a team to trade with. User team is Team A, other team is Team B. 2 - Calculate max points for both teams based on optimal lineups for the rest of the season, set this as a baseline level of points. 3 - Swap one player from Team A to Team B, and vice versa. 4 - Recalculate max points for both teams. 5 - Compare new max points against baseline. 6 - If new max points for both teams is higher than the baseline, the trade is a win-win trade for the two teams, so you store the traded players along with the net gain for each team. 7 - Repeat for every combination of one player for one player. 8 - Output results to user.

The user is then free to look over the list, find trades they really like, and send those trades over with the argument "look, Yahoo says its a win-win trade, these are rare and we should do this".

You can set automated scripts to look for 1x1 trades, 2x2 trades, and 3x3 trades between either the user and a specified team or between the user and all other teams. Would be an incredibly powerful tool to have.

amarvin commented 5 years ago

Great suggestion, thanks! I was thinking about something similar -- find the trade that looks like a win-win in the Yahoo trade eval screen, but maximizes your chance to win the season (e.g. makes them lose points during the week you play against them or helps them during the week they play your strongest competitor). I think it should be tractable to solve this as one MIP optimization problem that finds the best trade across all teams simultaneously, rather than looking for the best trade with each of the teams in your league.

Incogneat01234 commented 5 years ago

I built a similar trade finder in Excel, and 3 seasons into using it I have noticed most people don't care too much about the week to week matchups when compared to the whole. Most take win-win trades as 'may the best man win'. There are win% algorithms you can use to to really add some power to your tool - using historical performance to develop non-linear curves for expected pts for each player, generating weekly expected points nonlinear curve for each team each week, evaluating win% weekly and for the championship as a whole, and then evaluating any given move for championship win%. This is what advancedsportslogic.com would do before they shut down their tool. I loved it, but its a ton of work.

You are spot on with optimization, the whole trade scenario is rather simple set optimization. Same with waiver pickups. Looking forward to seeing where this goes.

amarvin commented 5 years ago

That's exactly what I'd like to have -- a calculation of league win% that is then used as the objective function for all my decisions. Do you know a formula for it as a function just of predicted points or a formula that also is a function of predicted points variance? I don't know a way to view or scrape the variance data from Yahoo, but assume they use it in their weekly matchup win% calculation.

One thought of mine is to scrape predicted scores from multiple sources (e.g. ESPN, Yahoo), calculate the mean and variance from those, and then write season win% assuming normal distributions.

Incogneat01234 commented 5 years ago

So I have seen no way to determine variance built into yahoo, that is part of their back end special sauce I believe. They also may not be doing anything crazy behind the scenes.

I know numberfire has paid weekly projections, and those projections have a stdv value associated with them. You can use that to calculate curves.

ESPN and Yahoo both use Rotowire for projections, so there would be no difference there.

One way to generate normal curves is on a position by position basis for each league. For example, it is currently week 3. For each RB in the league who has scored points, scrape projected and actual points for weeks 1 and 2. Use this information to develop a normal curve for RBs. Could be done for each position, and you can limit to top 50 players at each position if you like, or 25 for QBs and TEs. If you want to get even more in depth, you can silo players within the positions. An example of this would be to break RBs in week 1 into groups of 8 by projection, such that the top 8 in projection are a top group, next 8 are 2nd tier group, and so on and so forth. You can then generate normal curves for each tier - a projected top 8 rb has a normal distribution that looks like X, while a 9-16 rb has a normal that looks like Y. Then you apply those distributions based on the rbs weekly projected standing.

A lot of ways to go about generating the curve, but they all are huge huge data efforts.

See this patent for a bit more detail on this tier idea. https://patents.google.com/patent/US9082074B2/en?assignee=Advanced+Sports+Logic%2c+Inc.