Giter Club home page Giter Club logo

uberfastman / fantasy-football-metrics-weekly-report Goto Github PK

View Code? Open in Web Editor NEW
182.0 19.0 43.0 6.67 MB

Command line application to create weekly reports (containing stats, metrics, and rankings) for Fantasy Football leagues on the following platforms: Yahoo, Fleaflicker, Sleeper, ESPN.

License: GNU General Public License v3.0

Python 99.69% Shell 0.07% Dockerfile 0.24%
sleeper yahoo yahoo-fantasy-football fantasy-football fleaflicker fantasy-football-api yahoo-fantasy-api espn espn-fantasy-football espn-fantasy-api

fantasy-football-metrics-weekly-report's People

Contributors

markwhat1 avatar ragnarok56 avatar softsign avatar uberfastman 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fantasy-football-metrics-weekly-report's Issues

Pip module version issue

I set up everything according to the docs, but when I try to run a report, I get the following output:

2020-09-10 15:52:35,513 - root - ERROR - Error: (yahoo-oauth 0.1.9 (/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages), Requirement.parse('yahoo-oauth==1.0'), {'yfpy'})
Traceback (most recent call last):
File "main.py", line 49, in main
pkg_resources.require(dependency)
File "/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages/pkg_resources/init.py", line 899, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages/pkg_resources/init.py", line 790, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (yahoo-oauth 0.1.9 (/home/keith/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages), Requirement.parse('yahoo-oauth==1.0'), {'yfpy'})

2020-09-10 15:52:35,513 - root - ERROR - MISSING DEPENDENCY: yfpy>=3.0.0. Please run pip install yfpy>=3.0.0 and retry the report generation.
2020-09-10 15:52:35,707 - root - ERROR - MISSING 1 DEPENDENCY
...run aborted.

When I run the pip command mentioned in the error, I get the following:

2020-09-10 15:54:30,731 - root - ERROR - Error: (yahoo-oauth 1.0 (/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages), Requirement.parse('yahoo_oauth==0.1.9'))
Traceback (most recent call last):
File "main.py", line 49, in main
pkg_resources.require(dependency)
File "/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages/pkg_resources/init.py", line 899, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages/pkg_resources/init.py", line 790, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (yahoo-oauth 1.0 (/home/xxx/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.8/site-packages), Requirement.parse('yahoo_oauth==0.1.9'))

2020-09-10 15:54:30,732 - root - ERROR - MISSING DEPENDENCY: yahoo_oauth==0.1.9. Please run pip install yahoo_oauth==0.1.9 and retry the report generation.
2020-09-10 15:54:30,903 - root - ERROR - MISSING 1 DEPENDENCY
...run aborted.

Any thoughts?

Yahoo headshots config option

Currently the Yahoo reports use the high resolution headshots, which make the report PDFs enormous. There should be an option to use the low resolution thumbnails if users desire.

update luck metric

now that the zscore thing is in there, it could be another variable thrown in to the luck calculations. currently, luck is based entirely on how many other teams you would have beaten that week, and whether you actually won. but with zscore, we can throw in your negative luck based on your opponent outperforming themselves and the fact that you faced them during a week when the blew up, as well as that your own team underperformed that week

example:

wrens team weekly scores:
[45, 48, 47, 40, 134]

kevins team weekly scores:
[140, 120, 125, 155, 100]

in this case, wrens zscore is some outrageous number, indicating that he has completely outperformed his normal scores, while my scores were consistently high and i had a much lower score than my average, so negative zscore.

im not sure how to modify the luck metric to include a teams own zscore and their opponents zscore. just adding or multiplying doesnt seem sufficient... but maybe it is? just adding this for now.

No module named integrations.drive_integration

Not sure what's happening as I have changed anything since last week except for pulling the latest, but I know get the following error when running:

Running Fantasy Football Metrics Weekly Report application from within virtual environment...
Traceback (most recent call last):
  File "main.py", line 14, in <module>
    from integrations.drive_integration import GoogleDriveUploader
ImportError: No module named integrations.drive_integration
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Report feature configuration

Currently, if generating reports, you must have all the features/metrics/stats/etc. within the report. This task is to add configuration values to config.ini so that all features can be turned on/off per user preference.

Unable to successfully authenticate

I have followed the instructions you've included in the readme but have yet to successfully authenticate with Yahoo. I have installed the requirements and then ran the generate_report.py file. I answer 'y' and 'y' before it prompts me to visit an url in the format https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=xxxxxxxx. The resulting page is an error page titled Yahoo - 400 Bad Request with the following description.

Your browser sent a request that this server could not understand.
Please check the URL for proper spelling and capitalization. If you're having trouble locating a destination on Yahoo, try visiting the Yahoo home page or look through a list of Yahoo's online services. Also, you may find what you're looking for if you try searching below.

I am running this with Python 3.6 on Windows 10. I've tried to open the link in Chrome, Chrome in incognito mode, and Edge browser. Occasionally when I try in incognito it prompts me to login but after entering username and password it returns me to the same 400 Bad Request page. I've attached my python-yql.log if that might be helpful.

I'm super interested in what you've put together and would love to contribute if only I was able to get it off the ground!

python-yql.log

Add Appendix to explain Stats

Some of the metrics are not straightforward. An appendix to explain what they are and how they are calculated would improve the report.

Google Drive folder fetching bug

When using the Drive integration, the app searches for folders named Fantasy_Football, and the year of the report (2019 for instance), and then League_Name, before placing report.pdf into that final directory. However, say if 2019 already exists elsewhere in your Drive, it will stick the reports there instead, which is not desired behavior.

Median Score Metric

Some fantasy platforms support the ability for teams to also play against the league median score each week for an additional win/loss/tie. There should be a metric that ranks teams based on performance against the median.

error with positions

Hello, my league has an additional flex position that your script doesn't handle. Its a sleeper league and the api is REC_FLEX can be WR or TE. could you add this to the script. In the meantime I'll try to see if I can add it to the if check on the sleeper.py file.

Data source for historical player statuses

Currently many of the fantasy platforms (notably Yahoo) only provide CURRENT player statuses (OUT, SUSP, IR, BYE, etc.), so when using player statuses to determine coaching efficiency ineligibility, it is impossible to do so retroactively.

Check for `config.ini` before run

Several users have encountered "NoSectionError" when running the app because the config.ini file was not loaded properly due to not having been renamed. The app should check for the existence of this file before running and stop and warn the user if it does not exist.

Coaching efficiency over 100%

Hey Uber,

Just ran a report for a league of mine and coaching efficiency is showing at over 100% for several teams.

League number is 39617, Yahoo.

Thanks!

SSL validation error for nflarrest.com

Hey - I'm getting the below error when trying to generate a report. I'm getting ESPN data successfully, but can't seem to get past this.... Any help would be appreciated!

  • I'm using pyenv but I don't think that would affect this.
  • Is there a way to easily ignore the hostname miss-match?
  • Can I just disable the part of the report that comes from nflarrest.com?-- in the config.ini I tried league_bad_boy_rankings = False but that didn't seem to help, it still tries to get the data.
fantasy-football-metrics-weekly-report > python main.py   
Generate report for default league? (y/n) -> y
Generate report for default week? (y/n) -> y
2020-09-09 09:49:51,191 - report.builder - INFO - 
Generating Espn Fantasy Football report with settings:
    league id: XXREDACTED
    game id: nfl
    week: selected/default
    save_data: False
    refresh_web_data: False
    playoff_prob_sims: None
    break_ties: False
    dq_ce: False
    dev_offline: False
    test: False
on Sep 09, 2020...
2020-09-09 09:49:51,191 - report.builder - INFO - Retrieving fantasy football data from Espn API...
2020-09-09 09:50:20,014 - report.builder - INFO - ...retrieved all fantasy football data from Espn API in 0:00:28.822987

2020-09-09 09:50:20,015 - report.builder - INFO - Retrieving bad boy data from http://nflarrest.com website...
2020-09-09 09:50:20,146 - urllib3.connection - WARNING - Certificate did not match expected hostname: nflarrest.com. Certificate: {'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'San Francisco'),), (('organizationName', 'GitHub, Inc.'),), (('commonName', 'www.github.com'),)), 'issuer': ((('countryName', 'US'),), (('organizationName', 'DigiCert Inc'),), (('organizationalUnitName', 'www.digicert.com'),), (('commonName', 'DigiCert SHA2 High Assurance Server CA'),)), 'version': 3, 'serialNumber': '02493E07FA9E375A2DBBC61D94430FCF', 'notBefore': 'May  6 00:00:00 2020 GMT', 'notAfter': 'Apr 14 12:00:00 2022 GMT', 'subjectAltName': (('DNS', 'www.github.com'), ('DNS', '*.github.com'), ('DNS', 'github.com'), ('DNS', '*.github.io'), ('DNS', 'github.io'), ('DNS', '*.githubusercontent.com'), ('DNS', 'githubusercontent.com')), 'OCSP': ('http://ocsp.digicert.com',), 'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2HighAssuranceServerCA.crt',), 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ha-server-g6.crl', 'http://crl4.digicert.com/sha2-ha-server-g6.crl')}
Traceback (most recent call last):
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connection.py", line 396, in connect
    _match_hostname(cert, self.assert_hostname or server_hostname)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connection.py", line 406, in _match_hostname
    match_hostname(cert, asserted_hostname)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/ssl.py", line 334, in match_hostname
    % (hostname, ', '.join(map(repr, dnsnames))))
ssl.SSLCertVerificationError: ("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: MyHTTPSConnectionPool(host='nflarrest.com', port=443): Max retries exceeded with url: /api/v1/team/arrests/ARI (Caused by SSLError(SSLCertVerificationError("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 253, in <module>
    options.get("test", False))
  File "main.py", line 166, in select_league
    test=test)
  File "/XXREDACTED/userDir/dev/fantasy-football-metrics-weekly-report/report/builder.py", line 129, in __init__
    self.bad_boy_stats = self.league.get_bad_boy_stats(self.save_data, self.dev_offline, self.refresh_web_data)
  File "/XXREDACTED/userDir/dev/fantasy-football-metrics-weekly-report/dao/base.py", line 222, in get_bad_boy_stats
    refresh=refresh
  File "/XXREDACTED/userDir/dev/fantasy-football-metrics-weekly-report/calculate/bad_boy_stats.py", line 70, in __init__
    response = requests.get(nfl_arrest_api_team_base_url + team_abbr, headers=headers)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/XXREDACTED/userDir/.pyenv/versions/3.7.7/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: MyHTTPSConnectionPool(host='nflarrest.com', port=443): Max retries exceeded with url: /api/v1/team/arrests/ARI (Caused by SSLError(SSLCertVerificationError("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'")))

Superflex does not work on Yahoo

The coaching efficiency metric does not calculate correctly in my league, which I think is because of the superflex. Here are my roster settings... QB, RB, RB, WR, WR, TE, W/R/T, W/R/T, Q/W/R/T

Additionally, the weekly rankings on the luck rankings are I think double counting, as in my league, the ranks go up by 1,3,5,7,9,11, 11, 14, 16, 18, 20, 22. This might be because of the tie? Not sure....

ModuleNotFoundError

Hi Uberman,

Trying to get this running but I keep running into this error:

image

I've installed the requirements.txt for the report, and I do see some errors building src\rptlab, I'm not sure if they're related, but perhaps the requirements didn't install correctly. If I comment out the line 'from pydrive.auth import GoogleAuth' in drive.py, I see a ModuleNotFoundError in another place. Any idea where I've gone wrong?

Handle all Flex permutations

Currently the coaching efficiency calculations and player points by position will be messed up by unusual flex positions, or leagues that have multiple "types" of flex positions (WR/RB/TE and WR/RB, for instance). Currently if a league has one "regular" flex and one super flex (WR/RB/TE/QB) everything works, but this will still likely be an issue later, and so handling of flexes should be improved.

Setup.sh broke my bash_profile

Your setup.sh script adds text to .bash_profile without ensuring the new content starts on its own line. It resulted in a mashed up command that I had to go clean up.

H2H Record Playoff Tiebreaker

Currently, the playoff simulations only support "points for" as the tiebreaker after overall/division record. However, some league settings use head-to-head record to break ties. This would require a dynamic field containing a dictionary of opposing team ids as keys, and that team's record against each team as values, and then it would need to allow the user to define whether points for or h2h record dictates playoff eligibility tiebreakers.

Failure to generate report

so not sure if it is because i'm trying to run this on an incomplete week or not but i am receiving this error:

Traceback (most recent call last):
File "main.py", line 254, in
report_pdf = report.create_pdf_report()
File "c:\Scripts\Fantasy Football\fantasy-football-metrics-weekly-report\report\builder.py", line 389, in create_pdf_report
file_for_upload = pdf_generator.generate_pdf(filename_with_path, line_chart_data_list)
File "c:\Scripts\Fantasy Football\fantasy-football-metrics-weekly-report\report\pdf\generator.py", line 1182, in generate_pdf
if float(team[prob_ndx].split("%")[0]) == 100.00:
ValueError: could not convert string to float: '0-1-0 (0.000)'

config and log provided:

out.log
config.txt

Coaching efficiency tie-break for non-first

Currently, if there are coaching efficiency ties for places other than first, it still triggers the tied coaching efficiency report table additional columns. However, the coaching efficiency tie-break only resolves ties for first, since it requires separate REST API calls for each player for each past week. As such, it messes up the columns.

SSL Cert Verification Error for nflarrest.com

Running on mac for ESPN league, week 1.

Receive this error (looks like an SSL cert verification issue for nflarrest.com)

Running Fantasy Football Metrics Weekly Report application from within virtual environment...
Generate report for default league? (y/n) -> y
Generate report for default week? (y/n) -> y
2020-09-15 15:53:10,394 - report.builder - INFO - 
Generating Espn Fantasy Football report with settings:
    league id: 264523
    game id: nfl
    week: selected/default
    save_data: False
    refresh_web_data: False
    playoff_prob_sims: None
    break_ties: False
    dq_ce: False
    dev_offline: False
    test: False
on Sep 15, 2020...
2020-09-15 15:53:10,400 - report.builder - INFO - Retrieving fantasy football data from Espn API...
2020-09-15 15:53:25,089 - report.builder - INFO - ...retrieved all fantasy football data from Espn API in 0:00:14.689397

2020-09-15 15:53:25,090 - report.builder - INFO - Retrieving bad boy data from http://nflarrest.com website...
2020-09-15 15:53:25,504 - urllib3.connection - WARNING - Certificate did not match expected hostname: nflarrest.com. Certificate: {'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'San Francisco'),), (('organizationName', 'GitHub, Inc.'),), (('commonName', 'www.github.com'),)), 'issuer': ((('countryName', 'US'),), (('organizationName', 'DigiCert Inc'),), (('organizationalUnitName', 'www.digicert.com'),), (('commonName', 'DigiCert SHA2 High Assurance Server CA'),)), 'version': 3, 'serialNumber': '02493E07FA9E375A2DBBC61D94430FCF', 'notBefore': 'May  6 00:00:00 2020 GMT', 'notAfter': 'Apr 14 12:00:00 2022 GMT', 'subjectAltName': (('DNS', 'www.github.com'), ('DNS', '*.github.com'), ('DNS', 'github.com'), ('DNS', '*.github.io'), ('DNS', 'github.io'), ('DNS', '*.githubusercontent.com'), ('DNS', 'githubusercontent.com')), 'OCSP': ('http://ocsp.digicert.com',), 'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2HighAssuranceServerCA.crt',), 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ha-server-g6.crl', 'http://crl4.digicert.com/sha2-ha-server-g6.crl')}
Traceback (most recent call last):
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connection.py", line 397, in connect
    _match_hostname(cert, self.assert_hostname or server_hostname)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connection.py", line 407, in _match_hostname
    match_hostname(cert, asserted_hostname)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 323, in match_hostname
    % (hostname, ', '.join(map(repr, dnsnames))))
ssl.SSLCertVerificationError: ("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/connectionpool.py", line 727, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: MyHTTPSConnectionPool(host='nflarrest.com', port=443): Max retries exceeded with url: /api/v1/team/arrests/ARI (Caused by SSLError(SSLCertVerificationError("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 253, in <module>
    options.get("test", False))
  File "main.py", line 166, in select_league
    test=test)
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/report/builder.py", line 131, in __init__
    self.bad_boy_stats = self.league.get_bad_boy_stats(self.save_data, self.dev_offline, self.refresh_web_data)
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/dao/base.py", line 222, in get_bad_boy_stats
    refresh=refresh
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/calculate/bad_boy_stats.py", line 70, in __init__
    response = requests.get(nfl_arrest_api_team_base_url + team_abbr, headers=headers)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: MyHTTPSConnectionPool(host='nflarrest.com', port=443): Max retries exceeded with url: /api/v1/team/arrests/ARI (Caused by SSLError(SSLCertVerificationError("hostname 'nflarrest.com' doesn't match either of 'www.github.com', '*.github.com', 'github.com', '*.github.io', 'github.io', '*.githubusercontent.com', 'githubusercontent.com'")))
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...4 completed.

[Process completed]

KeyError: '24' when generating ESPN report

Running a report for an ESPN league and I get "KeyError: '24'"

Here is the output of the report generator:

Running Fantasy Football Metrics Weekly Report application from within virtual environment...
Generate report for default league? (y/n) -> y
Generate report for default week? (y/n) -> y
2020-09-11 00:34:39,595 - report.builder - INFO - 
Generating Espn Fantasy Football report with settings:
    league id: 264523
    game id: nfl
    week: selected/default
    save_data: False
    refresh_web_data: False
    playoff_prob_sims: None
    break_ties: False
    dq_ce: False
    dev_offline: False
    test: False
on Sep 11, 2020...
2020-09-11 00:34:39,601 - report.builder - INFO - Retrieving fantasy football data from Espn API...
The first week of the season is not yet complete. Are you sure you want to generate a report for an incomplete week? (y/n) -> y
Traceback (most recent call last):
  File "main.py", line 253, in <module>
    options.get("test", False))
  File "main.py", line 166, in select_league
    test=test)
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/report/builder.py", line 116, in __init__
    dev_offline=self.dev_offline
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/dao/utils.py", line 144, in league_data_factory
    dev_offline
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/dao/espn.py", line 87, in __init__
    self.matchups_by_week[str(week_for_matchups)] = self.league.box_scores(int(week_for_matchups))
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/dao/espn.py", line 524, in box_scores
    box_data = [BoxScore(matchup, pro_schedule, positional_rankings, week) for matchup in schedule]
  File "/Users/myuser/Documents/fantasy-football/fantasy-football-metrics-weekly-report/dao/espn.py", line 524, in <listcomp>
    box_data = [BoxScore(matchup, pro_schedule, positional_rankings, week) for matchup in schedule]
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/ff_espn_api/box_score.py", line 9, in __init__
    self.home_lineup = [BoxPlayer(player, pro_schedule, positional_rankings, week) for player in home_roster]
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/ff_espn_api/box_score.py", line 9, in <listcomp>
    self.home_lineup = [BoxPlayer(player, pro_schedule, positional_rankings, week) for player in home_roster]
  File "/Users/myuser/.virtualenvs/fantasy-football-metrics-weekly-report/lib/python3.7/site-packages/ff_espn_api/box_player.py", line 25, in __init__
    self.pro_pos_rank = positional_rankings[str(player['defaultPositionId'])][str(opp_id)]
KeyError: '24'
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Unless -p is defined at runtime report errors out.

Running latest commit from develop.

Exception has occurred: TypeError
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
File ".\report\pdf\generator.py", line 81, in init
self.playoff_prob_sims = int(playoff_prob_sims)
File ".\report\builder.py", line 305, in create_pdf_report
report_data=report_data
File ".\main.py", line 231, in
report_pdf = report.create_pdf_report()

Fleaflicker API updates for historical leagues

Currently, there are multiple issues with the Fleaflicker implementation revolving around properly getting data for the selected season and week, vs. the current season and week. These needs to be resolved.

Chanel_Not_Found Slack Integration

Having trouble with Slack integration. Added app following instructions exactly. Edited token and config. When I run the report, I get "integrations.slack_integration - ERROR - Slack client error: The request to the Slack API failed. The server responded with: {'ok': False, 'error': 'channel_not_found'}". It's a private channel, but I chose it from the list when installing app and it shows I added an integration in the channel. Tried googling on my own, I added bot user to channel. I tried formatting the name differently in config, including trying to use channel ID instead of name, with and without quotes, with or without #

Improve Coaching Efficiency

Currently coaching efficiency is calculated by taking your total score and dividing it by your optimal score, giving you a percentage rating for how close to picking the correct players to sit/start you were. However, this metric can be both gamed (picking up backup players who play or suit up but don't play much or at all), and is not robust against later weeks when lots of players are on bye or are injured.

As such, thought has gone into the appropriate way to improve this metric. The current working plan is to use joint probability calculations, such that we calculate n choose k for each starting lineup position (one QB slots w/3 QBs on the roster -> 3c1), and then multiplying that by each other starting lineup probability to get the joint probability of correctly picking an entire perfect lineup.

Additionally, in order to translate these probabilities into a usable ranking, some sort of weighting based on combining how close your selected position player's points were to the best points possible at that position and the probability of correctly selecting that player for that slot could be used to create a cumulative score.

Alternatively, the full joint probability could be combined with your actual points divided by optimal in some way to weight your coaching efficiency percentage by how hard it was to actually get that percentage.

This is an open issue, and will hopefully eventually result in a reliably robust coaching efficiency metric.

League standings are only ever current

Yahoo's API does not appear to provide league standings for any week other than the current one. As such, retrieving league standings for previous weeks does not work. This issue is tied to #39, and should be solved when that issue is.

[Feature Request] Add Potential Points somewhere in the report

First of all if theres a better way to handle this I apologize I look through the closed reports and didn't see any feature requests

Perfect lineups must be calculated while running this to tracking coaching efficiency? Could you look at adding the total potential points over the course of the season to the standings or its own table? Many dynasty leagues will determine non playoff draft order based on it. It would be nice to have that built into the report.

Thanks again!

Playoff predictions can't be used retroactively

Currently the Monte Carlo simulations used to create the playoff predictions use the current league standings data as a starting point. However, Yahoo's API seems to only provide the current standings, not the standings from a chosen week, which means if you run the playoff predictions for any week besides the current one they will not necessarily be correct, and can even run into an "index out of bounds" error.

To fix this, a custom Standings object needs to be built for each week using the results of that week's matchups, and then passed to the playoff probability calculator in order to emulate if Yahoo provided the chosen week's league standings.

Support for divisions

Currently there has been no testing at all for support of divisions. Eventually the report should support divisions, although it could require significant work to do so.

Generify Report Data

As the first step towards supporting additional platforms, the league data needs to use custom object types that can have various platform API data mapped to them.

Advanced Luck Metric

As proposed by @ragnarok56 previously, it would be nice to add a column to the luck table with a weighted luck metric that uses the z-scores of both teams in a matchup to weigh those teams' luck scores based on whether or not each team overperformed/underperformed.

See #27 and #30 for reference.

Testing

The app needs comprehensive unit and integration tests, as it currently has next to none.

Week 2 report failing

Trying to run the report for my ESPN league 321902

I dont know if i have a setting in the league that is causing issues or if im missing something in a config but I can not run report for week 2. I can successfully run week 1 report but if I try default week or even week 2 I get the following. Im not sure where the week1 metrics info coming from?

2020-09-23 08:08:02,898 - report.data - INFO -

              SCORE tie(s): 0
COACHING EFFICIENCY tie(s): 0

Traceback (most recent call last):
  File "main.py", line 254, in <module>
    report_pdf = report.create_pdf_report()
  File "C:\FFReport\report\builder.py", line 192, in create_pdf_report
    custom_weekly_matchups = self.league.get_custom_weekly_matchups(str(week_counter))
  File "C:\FFReport\dao\base.py", line 172, in get_custom_weekly_matchups
    winning_team = matchup.winner.team_id
AttributeError: 'NoneType' object has no attribute 'team_id'

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.