Git Product home page Git Product logo

draft-kings-fun's Introduction

Introduction · Build Status · ·

Blog · Web UI Demo · Slack Channel

This is an incredibly powerful tool that can automate lineup building, allowing you to enter thousands of lineups in any DK contest in the time it takes you to grab a coffee.

This project allows you to create an unlimited amount of optimized DraftKings lineups based on any projection source of your choice. You can use this repo as a command line application, or import functionality as needed to build your own scripts to construct thousands of DraftKings lineups each week and upload them in seconds using their CSV upload tool. Examples of how to do the latter are provided in the examples directory.

Special thanks to swanson, who authored this repo, which mine is heavily based off of.

Pre-reqs:

  • Python 2 but NOT Python 3 compatible yet (currently working on implementation)
  • ortools
  • pip install -r requirements.txt

To run, download your desired week's salaries on DraftKings, and then run:

bash scripts/prepare_nfl_contest_data.sh

Note that this script will error out if the CSV from DraftKings is not in ~/Downloads.

Next, scrape data from FantasyPros or Rotogrinders and allow for some mismatched data between the two sources:

python optimize.py -mp 100 -s y -source nfl_rotogrinders

Or, use your own projection source:

python optimize.py -mp 100 -s n -projection_file "/Users/benbrostoff/Downloads/my_projections.csv"

Note that any projection file you provide must include playername and points as header names.

One important note here is that passing in y for the scrape option will create current-projections.csv. However, once you've scraped once, there's no need to do again.

Optimization Options

Force a QB/WR or QB/TE combination from a particular team. For instance, if I wanted a guaranteed Cam Newton / Greg Olsen duo:

python optimize.py -mp 100 -duo CAR -dtype TE

Another example pairing Antonio Brown and Ben Roethlisberger:

python optimize.py -mp 100 -duo PIT -dtype WR

Limit same team representation except for QB / skill player combos. Example:

python optimize.py -mp 100 -limit y

Run the optimizer multiple times and continually eliminate pre-optimized players from the lineup. For instance, to run three different iterations and generate three different sets of players:

python optimize.py -i 3

At any time, you can get a list of all possible options via:

python optimize.py --help

Generating CSV for uploading multiple lineups to DraftKings

DraftKings allows uploading up to 500 lineups using a single CSV file. You can learn more about DraftKings' support for lineup uploads here. This tool supports generating an uploadable CSV file containing the generated optimized lineups.

To use this feature:

  1. Download the weekly salaries CSV from DraftKings (containing player name, DK-estimated points, salary, etc).
  2. Run bash scripts/prepare_<nba/nfl>_contest_data.sh.
  3. Download the CSV upload template and get the file location (probably something like ~/Downloads/DKSalaries.csv). Note - this file has the same name as the weekly salaries CSV when downloaded from DraftKings, which can be confusing.
  4. Run python optimize.py -pids <upload_tpl_location>. Remember to specify league, constraints, number of iterations to run, etc.
  5. Upload the newly generated file to DraftKings from data/current-upload.csv.

One nice workflow is to run the optimizer with the -keep_pids flag after you create your CSV; this option will put future optimizations in the same CSV file.

Projected Ownership Percentages (Experimental)

Projected ownership percentages as of this writing could be downloaded from DFS Report. If you download the CSV, you can filter on projected ownership percentage. For example, only include players below 15% owned.

python optimize.py -po_location 'data/ownership.csv' -po 15

MLB (NEW! April 2018)

After downloading the DraftKings salaries for a contest:

bash scripts/prepare_contest_data.sh

Currently, Rotogrinders is the only available datasource that can be scraped:

python optimize.py -league MLB -source mlb_rotogrinders

NBA

An NBA option exists for NBA contests. After downloading the DraftKings salaries for a contest:

bash scripts/prepare_contest_data.sh

Currently, Rotogrinders and Numberfire are the only available datasources:

python optimize.py -league NBA -source nba_rotogrinders
python optimize.py -league NBA -source nba_number_fire

WNBA

A WNBA option is available, but users must provide their own projection source:

bash scripts/prepare_contest_data.sh
python optimize.py -league WNBA -projection_file "/Users/benbrostoff/Downloads/my_projections.csv" -s No

Pick'Em (NEW! January 2018)

Pick'Em contests allow players to pick one player in each of six tiers. After downloading a salaries file:

bash scripts/prepare_contest_data.sh
python pickem_optimize.py

Historical Optimization (NEW! February 2018)

Interested in knowing the best possible lineup for a given day? The -historical_date flag will allow you to experiment with data from previous contests. Example:

python optimize.py -league NBA -historical_date "2018-02-23"

The results can show some amazingly high scores and lead to critical insights about how to structure lineups:

This flag only works for NBA and the data collected from the draft_kings_nba module.

For a list of available flags and filters:

python pickem_optimize.py --help

You can also automate lineup construction for Pick'Em contests. It is recommended you do this via scripting versus the CLI. An example is shown in examples/random_pickem_nba.py.

Note that for all CSV lineup uploads, you need to download the the template for the day's games here. Make sure to switch the sport to NBA and style to Pick Em.

draft-kings-fun's People

Contributors

benbrostoff avatar kacperadach avatar coryz avatar bissont avatar

Watchers

James Cloos avatar alyssamhope avatar

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.