Coder Social home page Coder Social logo

draftkings's Introduction

DraftKings

A project to optimize lineups for Daily Fantasy Sports (DraftKings) starting with the NBA

Development Environment Setup

Some quick instructions for getting dev environment setup for Python parts of the pipeline (assuming Mac)

Install pyenv virtual env

$ brew install pyenv-virtualenv

Add the following lines to your ~/.bash_profile file

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi                                       
 if which pyenv-virtualenv-init > /dev/null; then
     eval "$(pyenv virtualenv-init -)";
fi

Install python

$ pyenv install 3.7.4

Create a new virtual environment and activate

pyenv virtualenv 3.7.4 draftkings
pyenv activate draftkings

Install python packages

pip install -r requirements.txt

The Problem

We can frame this as a linear programming optimization problem. That is we are trying to pick 8 players let's call it:

  • P_1 = (s1, p1)
  • P_2 = (s2, p2)
  • P_3 = (s3, p3)
  • P_4 = (s4, p4)
  • P_5 = (s5, p5)
  • P_6 = (s6, p6)
  • P_7 = (s7, p7)
  • P_8 = (s8, p8)

where s = salary and p = points. and P_i is a player

We are trying to

max(p1 + p2 + ... + p8)

subject to the constraint

s1 + ... + s8 = 50000

In addition, for basketball there are position constraints as well.

Planned Work

  1. Figure out how to (pref automatically) download DraftKings to get salary data. For now, we will manually download it by going to the context and exporting to CSV. Data is stored in data/raw
  2. Figure out how to (pref automatically) download player stats per game. We really only need the stats that matter for draft kings, so Points, steals, blocks, assists, TO, 3 points made, and from there we can derive double-double, triple double, etc. After downloading the data, we'll need to use DraftKing's formula to convert to DraftKings Points.

As of 2020-08-05, the scoring rules are:

Stat DraftKings Points
Point +1
Made 3 pt Shot +0.5
Rebound +1.25
Assist +1.5
Steal +2
Block +2
Turnover -0.5
Double-Double +1.5
Triple-Double +3
  1. Figure out how to (pref automatically) submit lineups to DraftKings.

Potentially Useful Links

  1. https://realpython.com/linear-programming-python/?fbclid=IwAR0WL4TShqaOHSJTcZFQZZ7QCfe1JmgAewu9V8RrvDOlPipQ7eAZ6FuohZA
  2. https://github.com/jaebradley/draftkings_client
  3. Python Package for Scraping Basketball Reference for Box Scores

draftkings's People

Contributors

kge001 avatar vincentla avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

draftkings's Issues

Build mapping table for data sources

Create unique IDs for players and map to various data sources. Currently using data from:

  1. nba.com injury reports (Name)
  2. DK salary tables (Name)
  3. basketball reference box scores (slug)

Along this, write function that flags unmapped player data

Set up backtesting capabilities

Will need to restructure the optimizer code - package optimizer in a function call that can be flexibly used. Functions required:
Predicted Lineup = Optimizer, given salary and EV/predictions
Best Possible = Optimize, given salary and actual box scores
Actual performance of Predicted = Function that calculated DK pts, given player list + date

These to be called in a wrapper function that will run with date range and output options

During live testing, it would be useful to also gather data on score of cashing/breakeven/top10%/top5%/top etc if possible so that we can estimate these on dates we arent playing

Modularize code and add configuration file

I was thinking of organizing the code by putting our models in the following places:
-prediction_models.py
-risk_models.py
The optimizer can have a ton of parameters applied to it like dates run, output dir, which prediction model, which risk model, injury data, just to name a few. I was thinking we should have a config file to manage these where the optimizer will load the information in the file and run based on those settings. Have you used .yaml files before?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.