Programming in Daily Fantasy Sports


Personal

Updated Jun 3rd, 2021

Can you use the power of programming to gain a competitive edge in DFS?

Someone much smarter than me already ran the experiment I was thinking of. Read his article here. The gist is that the projected points has a lot of variation with actual points so there shouldn’t be a competitive advantage. I think with digging deeper and iterating over this base there may be more here. (Think standard deviation, custom projections, etc.)

One of the first things I need to do is create the model and, based on my skill set, this is not easy to do. I like the challenge though and think this would be a great learning opportunity although I cannot let this become a rabbit hole of time.

I would like to test the strategy on single night games which I find to be just so damn boring. Another question that arises is bankroll. I would like to test for a bit with low dollar entry and then, if it makes sense to do so, increase the buy-in amounts before too much of the season has passed. The question for me becomes, how many attempts are needed to try it out and see if it’s working (for instance, one game isn’t clearly good enough but is 25?). There are 3 standalone NFL games a week. Multiplied by 17 weeks the number of games is 51. But there are some weeks where there are no games and some weeks where I will likely miss the game. 20 games sounds like a decent testing period. This should also be tested in single entry 50/50 games or double ups with at least 50 people to give a good enough sample.

Captain Mode

So single games require a variation on your typical DFS game styles. One of the first thing that come to mind is in order to create a lineup and do one single game you can’t do classic as far as game styles I do see one game available for the showdown captain mode I see one game available for in-game showdown H2 which probably tells me there’s some sort of half or quarter there’s a Madden showdown captain which I don’t think that’s it cuz it’s 4:00 and there’s a night game and then tears shows 12 games for the 13th so it looks like for me it’s between showdown Captain mode. on the DraftKings site it says in salary cap contest participants will create a lineup by selecting players listed in the player pool contest results will be determined by the total points accumulated by each individual lineup entry participation each contest must be made only as specified in the terms of use. blah blah blah looks like the player you drafted your captain will earn 1.5 times the standard fantasy point value for each statistic. Well this seems like it adds another element. clicking back to classic it looks like you have to include players from at least two different NFL games.

Gathering the Data

and starting to look at some football projections for week one it shows that there’s consensus of four sources and it’s important to note that there’s a date so it’s interesting to think like when are the consensus rankings like how soon are you looking at the consensus rankings versus the actual event. I think it would make sense to look at it on the day of. It’s also interesting to see of the sources you can pick sources there’s four and you can disclude some of them. from a scraping perspective it looks like you have separate tabs for The different positions and at first glance they don’t have it in one big sheet.

You can download projected points for each position to a spreadsheet if you’re logged in for free. Could create a web scraping script to download into one Excel workbook and then create a VLOOKUP. I see salary data based on FanDuel salary changes to DraftKings. DraftKings has an export feature for players and salaries for selected contests.

Finding the Number of Possible Lineups

This is a fairly simple math problem using factorials and combination. The numbers get very large very quickly.

Print the Possible Lineups

This is where I start to run into trouble and the knowledge gap becomes apparent. I know some code for basic web development but this requires some hard core programming skills that require understanding algorithms and solving complex match problems with code.

Calculate If the Lineup is Under the Salary Cap

You go from storing names in a lineup to referencing a players salary and then adding them up and removing any lineups under the $50,000 salary cap. This is hard enough without having to consider the selection of a captain at a 1.5x mutltiplier.

If the Lineup is under the salary cap calculate and rank the lineup’s projected points.

If you can calculate the salary cap then this should be fairly easy, the sorting as well.

Add Back the Captain Concept

As if the previous steps weren’t hard enough now you need to take the lineups and consider test if any of them were selected as captain would you still be under budget and, if so, what would the new ranking of projected points be.

OR Go RANDOM

Random gets around the test every possible scenario headaches while still using the power of computer programming to potentially provide an edge.

The loop has to be involved

Issues getting from console to screen

Randomize thousands of lineups that meet the salary and projected points threshold and put resulting promising lineups in new array and print this new array to html table.

Finding and subsequently neglecting duplicate lineups may not be as crazy as originally thought. You can scrap the qb (and even dst in classic).

Does one match two? No. Does one match three and so on.

Afterwards does 2 match 3. Yes or No. does 2 match 4. No.

If passes duplicate scan and meets minimum point threshold then print lineup to the table. Sounds like filter. Can do it.

Lineuo generator and Excel file used in conjunction

This lineups in the first week were created only using the Excel file because the lineup generator was In the process of being created. I would just put a check mark in a column label team one team too and then you know kind of make sure that it was under the salary cap and who had the most projected scores and it was very manual but by adding players that were conditionally formatted as and being highlighted for good value and then once you got down to like two players using number filters to make sure that you were only looking at players with a certain salary cap. LineUPS created manually with excel are still a decent starting point and is still a pretty decent. The line of generator really helps out with captain mode. regardless of which place you start it’s good to go back and check it for the other. So for instance if I’ve used Excel file to manually create a lineup and I created three lineups and I take the highest point value just put that point value in the lineup generators and instantly you find something better. also if you create something with the line of generator go back through the Excel file and see if you can increase anyone’s points by utilizing any remaining budget or switching out one player that’s projected higher for similar budget.

Random

Your only as good as your next loss. Or your next string of losses, which can strike at anytime. Stay humble.

In a typical year Football is Sept – Jan, MLB is April – Oct, NHL is Oct-Mar. Not a huge fan of basketball and Gold seems interesting but few and far between.

In Classic No More than 2 offensive players from the same team. The early slate in week 3 my lineup just got crushed It had Cam Newton three receivers on New England so four of my nine players was relying on a successful New England offense and it just didn’t happen. I think I scored like 4:44 out of 4:45 in one of the lineups like no kidding It was f****** bloodbath. fortunately I had success in the late window and the Sunday night game and the Thursday night game and even the Sunday all day game but yeah I was on the first loss I lost big.

Pull weekly scoring results and use Coefficient of Variation (Standard Deviation divided by the mean) to find players that are lower risk for double ups. Injuries can cloud the numbers, bye weeks are something to watch out for. Maybe a three or four week rolling.

I know it’s practically impossible but I think it’s good to only check your lineups every quarter or every certain amount of time to avoid the emotional roller coaster that is constant updates.

Alvin Zeidenfeld is all over youtube on the fantatsy sports.

Lessons from Fantasy Baseball

Ks are King and Strikeouts per $ spent is a thing.

No more than 5 non pitchers from the same team in a lineup.

dfsondemand.com had a video on MLB I watched. Stressed the importance of Excel, vlookups, indexes, and if errors. RickRungood.com was the site i was re-routed to.

Few lessons learned from testing baseball: The competition is higher and I don’t want to get in any double yup contest unless it’s single entry and over 100 entries. Entered some contest with only 20 -30 people and sometimes over 50% of the field had the same lineup. I would check the badges on the other players and they all had their expert badge on although not sure if that means much. The lineups are reliant on pitchers and the rest of the team is very boom or bust because not a lot of action in baseball. A lot of movement in projections as lineups come out late sometimes and weather plays such a large factor. If you are playing and watching it’s good to print or write out the batting orders of the teams and use MLB.com to keep an eye on where a game is at in the order.

Daily Fantasy Nerd has a badass optimizer Color coded conditional formatting in browser table. Use Las Vegas odds to calculate implied win probability. Weather powered by forecast.io as weather plays a huge factor in baseball. historical back testing for field, temp, wind. Floor and ceilings based on standard deviations. Hitters an pitchers are often in two separate tables since they have different metrics. Min/max salary cap sliders or inputs could be cool. Checkbox for which position to include/exclude as captain and flex positions is cool.

In testing baseball I checked out a few site that offer projections. Ended up checking out roto grinders for 5 days for $15. All sites have similar features and multiple tier offerings between 30-40 a month and then a higher tier at 70-80 a month. Awesomo was $120 a week and $360 a month!? A few must have things for me the projections needed to be DK specific and be able to export projections as CSV. fangraphs.com seemed to have some free data projection data but not sure how reliable.


Top