Giter VIP home page Giter VIP logo

fpl-optimiser's Introduction

FPL optimiser

Use linear programming to find the optimal fantasy football (soccer) squad.

This is not my idea and was originally (to my knowledge) by Martin Eastwood. You can find his blog post here: http://www.pena.lt/y/2014/07/24/mathematically-optimising-fantasy-football-teams/

The code was written on python 3.5.

How to use it

This repo contains two main modules. fetch_fpl_history downloads the data from the fpl website. optimise allows you to find the optimal squad for a given season.

Usage is pretty simple. Just run the following two commands from the command line:

> python fetch_fpl_history.py
> python optimise.py

This will output an optimised squad, like the example below:

Position               Name  Cost  Points
Goalkeeper         Tom Heaton   5.0   149.0
Goalkeeper     Fraser Forster   5.0   134.0
  Defender    Charlie Daniels   5.0   134.0
  Defender  César Azpilicueta   6.5   170.0
  Defender        Gary Cahill   6.5   178.0
  Defender      Marcos Alonso   7.0   177.0
  Defender     Gareth McAuley   5.0   131.0
Midfielder          Joe Allen   5.5   118.0
Midfielder  Christian Eriksen   9.5   218.0
Midfielder      Bamidele Alli   9.5   225.0
Midfielder     Etienne Capoue   5.5   131.0
Midfielder   Robert Snodgrass   6.0   133.0
   Forward        Joshua King   7.5   178.0
   Forward      Jermain Defoe   8.0   166.0
   Forward    Roberto Firmino   8.5   180.0

Total cost:     100.0
Total points:   2422.0
Formation:      2-5-5-3

Notes

Some notes on each of the modules

fetch_fpl_history

fetch_fpl_history fetches the data from the FPL website and saves it to data/fpl_history.csv.

This file includes a call to time.sleep so that we don't overload the FPL website's servers. Please bear this in mind and when scraping.

optimise

Once you have downloaded the data, you can run python optimise.py from the command line to find the optimal squad.

You can optionally change the optimiser's constraints with some command line arguments. For instance, if you wanted to run the optimiser with a different budget to the default £100, you can run python optimise.py --budget 105.

Another option is to supply a different formation to the default 2-5-5-3. For example if you wanted to optimise the first XI players (replacing the remaining squad places with £4.0 players), you could try python optimise.py --formation 1-4-4-2 or python optimise.py --formation 1-3-4-3.

Or perhaps you've already decided which star striker (£10) you'll put in your team and want to optimise the rest of the squad python optimise.py --formation 2-5-5-2 --budget 90

fpl-optimiser's People

Contributors

torvaney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fpl-optimiser's Issues

Re: Incomplete Fetch

Hi,

After running fetch fpl_history, it is expected to download 1000 records, however program always fetches 548 of them and hence optimize file shows old squad 11.
screenshot 36

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.