Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fantasy-football-lineup

fantasy-football-lineup is a tool to find the optimal lineup for manager games.

It was used for:

Usage example

> pip install -r requirements.txt
> python obtain_data.py
> python choose_team.py
+---------------------+------------------+-------------+-----------------------+-----------------------+-------------------------+
|       Position      |       Name       |     Club    | Ingame value [Mio. €] | Market value [Mio. €] | Ratio (market / ingame) |
+---------------------+------------------+-------------+-----------------------+-----------------------+-------------------------+
| Position.GOALKEEPER |   joan garcia    |   spanien   |          2.0          |          45.0         |          22.50          |
| Position.GOALKEEPER |   robin roefs    | niederlande |          1.0          |          28.0         |          28.00          |
|  Position.DEFENDER  | henrik falchener |   norwegen  |          1.0          |          6.0          |           6.00          |
|  Position.DEFENDER  | joaquin piquerez |   uruguay   |          1.0          |          12.0         |          12.00          |
|  Position.DEFENDER  | lucas herrington |  australien |          1.0          |          4.5          |           4.50          |
|  Position.DEFENDER  |   nathan ngoy    |   belgien   |          2.0          |          25.0         |          12.50          |
|  Position.DEFENDER  |   willer ditta   |  kolumbien  |          1.0          |          5.5          |           5.50          |
| Position.MIDFIELDER |    erik lira     |    mexiko   |          1.0          |          12.0         |          12.00          |
| Position.MIDFIELDER | jude bellingham  |   england   |          8.0          |         130.0         |          16.25          |
| Position.MIDFIELDER |  moises caicedo  |   ecuador   |          6.0          |         100.0         |          16.67          |
| Position.MIDFIELDER |      pedri       |   spanien   |          8.0          |         150.0         |          18.75          |
| Position.MIDFIELDER |     vitinha      |   portugal  |          8.0          |         140.0         |          17.50          |
|   Position.FORWARD  |  erling haaland  |   norwegen  |          10.0         |         200.0         |          20.00          |
|   Position.FORWARD  |  kylian mbappe   |  frankreich |          10.0         |         180.0         |          18.00          |
|   Position.FORWARD  |   lamine yamal   |   spanien   |          10.0         |         200.0         |          20.00          |
|          -          |      Total       |             |          70.0         |         1238.0        |          17.69          |
+---------------------+------------------+-------------+-----------------------+-----------------------+-------------------------+

This example team is not based on the latest data. To get the best team, you should try yourself ;)

For extended usage, check the help of obtain_data.py. There are some useful flags for printing the players with the highest market to ingame value ratio, excluding players and refreshing the cache.

Detailed workflow

Step Modules
Parse available players from https://gaming.uefa.com/de/uefaeuro2020fantasyfootball Selenium, because player list needs to be scrolled down
Parse market values from https://www.transfermarkt.de Beautifulsoup
Match available players and their market values via player names
Cache the data Pickle (intermediate data), csv (completed player list)
Find players with the highest market value, who still fit in the budget and in the formation Pyomo, Pandas
Print the chosen players Prettytable

Potential improvements

Consider more metrics than just the market value. The players with highest market values aren't guaranteed to play. Possible metrics:

  • Ratings of the last year (club and national team)
  • Appearances in the national team in the last year
  • Bonus for penalty shooters

The metrics should be obtainable without many requests. Preferably team wise or even in a single database.

A known issue is that the script can't resolve duplicated names. Duplicated means the first letter of the first name and family name are identical. This could be fixed only with an ID system.

Further links

This blog post inspired me to write these scripts: https://thedatabarista.wordpress.com/2015/01/27/pyomo-meets-fantasy-football/.

Releases

Packages

Contributors

Languages