A project to optimize lineups for Daily Fantasy Sports (DraftKings) starting with the NBA
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
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.
- 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
- 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 |
- Figure out how to (pref automatically) submit lineups to DraftKings.