All Projects → BenBrostoff → Draftfast

BenBrostoff / Draftfast

A tool to automate and optimize DraftKings and FanDuel lineup construction.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Draftfast

Basketball analytics
Repository which contains various scripts and work with various basketball statistics
Stars: ✭ 88 (-54.17%)
Mutual labels:  nba
Lookahead pytorch
pytorch implement of Lookahead Optimizer
Stars: ✭ 138 (-28.12%)
Mutual labels:  optimizer
Nba Movement Data
SportVU movement tracking data.
Stars: ✭ 154 (-19.79%)
Mutual labels:  nba
Adamw keras
AdamW optimizer for Keras
Stars: ✭ 106 (-44.79%)
Mutual labels:  optimizer
Keras Adabound
Keras implementation of AdaBound
Stars: ✭ 129 (-32.81%)
Mutual labels:  optimizer
React Lite
An implementation of React v15.x that optimizes for small script size
Stars: ✭ 1,734 (+803.13%)
Mutual labels:  optimizer
All Nba
Android app for NBA fans. Features live scores, highlights and Reddit integration for discussions.
Stars: ✭ 65 (-66.15%)
Mutual labels:  nba
Nbash
观看NBA比分直播,球员数据的命令行程序。
Stars: ✭ 176 (-8.33%)
Mutual labels:  nba
Image Optimize Command
Easily optimize images using WP CLI
Stars: ✭ 138 (-28.12%)
Mutual labels:  optimizer
Flutter app
🔥🔥🔥本项目包括各种基本控件使用(Text、TextField、Icon、Image、Listview、Gridview、Picker、Stepper、Dialog、Slider、Row、Appbar、Sizebox、BottomSheet、Chip、Dismissible、FlutterLogo、Check、Switch、TabBar、BottomNavigationBar、Sliver等)、豆瓣电影、tubitv、每日一文、和天气、百姓生活、随机诗词、联系人、句子迷、好奇心日报、有道精品课、高德定位、音乐播放器🎵、追书神器等板块
Stars: ✭ 2,140 (+1014.58%)
Mutual labels:  nba
Glsl Optimizer
GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.
Stars: ✭ 1,506 (+684.38%)
Mutual labels:  optimizer
Nba Prediction
Predict scores of NBA games using regularized matrix completion
Stars: ✭ 128 (-33.33%)
Mutual labels:  nba
Deepplaybyplay
Labelling NBA action using deep learning 🏀
Stars: ✭ 143 (-25.52%)
Mutual labels:  nba
Nbareact
🏀 iOS and Android NBA app created with React Native
Stars: ✭ 101 (-47.4%)
Mutual labels:  nba
Nba Player Movement
Visualization and analysis of NBA player tracking data
Stars: ✭ 156 (-18.75%)
Mutual labels:  nba
Viz torch optim
Videos of deep learning optimizers moving on 3D problem-landscapes
Stars: ✭ 86 (-55.21%)
Mutual labels:  optimizer
Nn dataflow
Explore the energy-efficient dataflow scheduling for neural networks.
Stars: ✭ 141 (-26.56%)
Mutual labels:  optimizer
Nba Live
Watch NBA games in the terminal, the content in Chinese only.
Stars: ✭ 181 (-5.73%)
Mutual labels:  nba
Image Optimizer
Easily optimize images using PHP
Stars: ✭ 2,127 (+1007.81%)
Mutual labels:  optimizer
Pytorch Optimizer
torch-optimizer -- collection of optimizers for Pytorch
Stars: ✭ 2,237 (+1065.1%)
Mutual labels:  optimizer

Introduction · Build Status · ·

An incredibly powerful tool that automates and optimizes lineup building, allowing you to enter thousands of lineups in any DraftKings or FanDuel contest in the time it takes you to grab a coffee.

Installation

Requires Python 3.6.

pip install draftfast

Usage

Example usage (you can experiment with these examples in repl.it):

from draftfast import rules
from draftfast.optimize import run
from draftfast.orm import Player
from draftfast.csv_parse import salary_download

# Create players for a classic DraftKings game
player_pool = [
    Player(name='A1', cost=5500, proj=55, pos='PG'),
    Player(name='A2', cost=5500, proj=55, pos='PG'),
    Player(name='A3', cost=5500, proj=55, pos='SG'),
    Player(name='A4', cost=5500, proj=55, pos='SG'),
    Player(name='A5', cost=5500, proj=55, pos='SF'),
    Player(name='A6', cost=5500, proj=55, pos='SF'),
    Player(name='A7', cost=5500, proj=55, pos='PF'),
    Player(name='A8', cost=5500, proj=55, pos='PF'),
    Player(name='A9', cost=5500, proj=55, pos='C'),
    Player(name='A10', cost=5500, proj=55, pos='C'),
]

roster = run(
    rule_set=rules.DK_NBA_RULE_SET,
    player_pool=player_pool,
    verbose=True,
)

# Or, alternatively, generate players from a CSV
players = salary_download.generate_players_from_csvs(
  salary_file_location='./salaries.csv',
  game=rules.DRAFT_KINGS,
)

roster = run(
  rule_set=rules.DK_NBA_RULE_SET,
  player_pool=players,
  verbose=True,
)

You can see more examples in the examples directory.

Game Rules

Optimizing for a particular game is as easy as setting the RuleSet (see the example above). Game rules in the library are in the table below:

League Site Reference
NFL DraftKings DK_NFL_RULE_SET
NFL FanDuel FD_NFL_RULE_SET
NBA DraftKings DK_NBA_RULE_SET
NBA FanDuel FD_NBA_RULE_SET
MLB DraftKings DK_MLB_RULE_SET
MLB FanDuel FD_MLB_RULE_SET
WNBA DraftKings DK_WNBA_RULE_SET
WNBA FanDuel FD_WNBA_RULE_SET
PGA FanDuel FD_PGA_RULE_SET
NASCAR FanDuel FD_NASCAR_RULE_SET
SOCCER DraftKings DK_SOCCER_RULE_SET
EuroLeague DraftKings DK_EURO_LEAGUE_RULE_SET
NHL DraftKings DK_NHL_RULE_SET
NBA Pickem DraftKings DK_NBA_PICKEM_RULE_SET
NFL Showdown DraftKings DK_NFL_SHOWDOWN_RULE_SET
NBA Showdown DraftKings DK_NBA_SHOWDOWN_RULE_SET
MLB Showdown DraftKings DK_MLB_SHOWDOWN_RULE_SET
XFL DraftKings DK_XFL_CLASSIC_RULE_SET
Tennis DraftKings DK_TEN_CLASSIC_RULE_SET
CS:GO DraftKings DK_CSGO_SHOWDOWN

Note that you can also tune draftfast for any game of your choice even if it's not implemented in the library (PRs welcome!). Using the RuleSet class, you can generate your own game rules that specific number of players, salary, etc. Example:

from draftfast import rules

golf_rules = rules.RuleSet(
    site=rules.DRAFT_KINGS,
    league='PGA',
    roster_size='6',
    position_limits=[['G', 6, 6]],
    salary_max=50_000,
)

Settings

Usage example:

class Showdown(Roster):
    POSITION_ORDER = {
        'M': 0,
        'F': 1,
        'D': 2,
        'GK': 3,
    }


showdown_limits = [
    ['M', 0, 6],
    ['F', 0, 6],
    ['D', 0, 6],
    ['GK', 0, 6],
]

soccer_rules = rules.RuleSet(
    site=rules.DRAFT_KINGS,
    league='SOCCER_SHOWDOWN',
    roster_size=6,
    position_limits=showdown_limits,
    salary_max=50_000,
    general_position_limits=[],
)
player_pool = salary_download.generate_players_from_csvs(
    salary_file_location=salary_file,
    game=rules.DRAFT_KINGS,
)
roster = run(
    rule_set=soccer_rules,
    player_pool=player_pool,
    verbose=True,
    roster_gen=Showdown,
)

PlayerPoolSettings

  • min_proj
  • max_proj
  • min_salary
  • max_salary
  • min_avg
  • max_avg

OptimizerSettings

  • stacks - A list of Stack objects. Example:
roster = run(
    rule_set=rules.DK_NHL_RULE_SET,
    player_pool=player_pool,
    verbose=True,
    optimizer_settings=OptimizerSettings(
        stacks=[
            Stack(team='PHI', count=3),
            Stack(team='FLA', count=3),
            Stack(team='NSH', count=2),
        ]
    ),
)

Stack can also be tuned to support different combinations of positions. For NFL, to only specify a QB-WRs based stack of five:

Stack(
    team='NE',
    count=5,
    stack_lock_pos=['QB'],
    stack_eligible_pos=['WR'],
)
  • custom_rules - Define rules that set if / then conditions for lineups. For example, if two WRs from the same team are in a naturally optimized lineup, then the QB must also be in the lineup. You can find some good examples of rules in draftfast/test/test_custom_rules.py.
from draftfast.optimize import run
from draftfast.settings import OptimizerSettings, CustomRule

# If two PGs on one team, play the C from same team
settings = OptimizerSettings(
    custom_rules=[
        CustomRule(
            group_a=lambda p: p.pos == 'WR' and p.team == 'SomeTeam',
            group_b=lambda p: p.pos == 'QB' and p.team == 'SomeTeam',
        )
    ]
)
roster = run(
    rule_set=rules.DK_NFL_RULE_SET,
    player_pool=nfl_pool,
    verbose=True,
    optimizer_settings=settings,
)

Custom rules also don't have to make a comparison between two groups. You can say "never play these two players in the same lineup" by using the CustomRule#comparison property.

# Never play these two players together
settings = OptimizerSettings(
    custom_rules=[
        CustomRule(
            group_a=lambda p: p,
            group_b=lambda p: p.name == 'PlayerA' or p.name == 'PlayerB',
            comparison=lambda sum, a, b: sum(b) <= 1
        )
    ]
)

LineupConstraints

  • locked - list of players to lock
  • banned - list of players to ban
  • groups - list of player groups constraints. See below
roster = run(
    rule_set=rules.DK_NFL_RULE_SET,
    player_pool=player_pool,
    verbose=True,
    constraints=LineupConstraints(
        locked=['Rob Gronkowski'],
        banned=['Mark Ingram', 'Doug Martin'],
        groups=[
            [('Todd Gurley', 'Melvin Gordon', 'Christian McCaffrey'), (2, 3)],
            [('Chris Carson', 'Mike Davis'), 1],
        ]
    )
)
  • no_offense_against_defense - Do not allow offensive players to be matched up against defensive players in the optimized lineup. Currently only implemented for soccer, NHL, and NFL -- PRs welcome!

CSV Upload

from draftfast.csv_parse import uploaders

uploader = uploaders.DraftKingsNBAUploader(
    pid_file='./pid_file.csv',
)
uploader.write_rosters(rosters)

Support and Consulting

DFS optimization is only one part of a sustainable strategy. Long-term DFS winners have the best:

  • Player projections
  • Bankroll management
  • Diversification in contests played
  • Diversification across lineups (see draftfast.exposure)
  • Research process
  • 1 hour before gametime lineup changes
  • ...and so much more

DraftFast provides support and consulting services that can help with all of these. Let's get in touch today.

Contributing

Run tests or set of tests:

# All tests
nosetests

# Single file
nosetests draftfast/test/test_soccer.py

# Single test
nosetests draftfast/test/test_soccer.py:test_soccer_dk_no_opp_d

Run linting

flake8 draftfast

Credits

Special thanks to swanson, who authored this repo, which was the inspiration for this one.

Current project maintainers:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].