nealmick / Sports-Betting-ML-Tools-NBA

NBA Machine Learning and Market Analysis Tools
https://firebet.ai
44 stars 3 forks source link

How do you update rosters? #28

Closed Wolf242 closed 1 year ago

Wolf242 commented 1 year ago

Charlotte Hornets still has Kelly Oubre Jr on it.

nealmick commented 1 year ago

This on local server or live?? https://nbadata.cloud/predict/player-details/360 https://nbadata.cloud/predict/team/CHA Maybe already clicked update?

live server seems to be correct. We have no way of detecting when a player is traded, we can only observe data changes when we see them. Each player can also be manually updated from the ui... bolth there team and season averages, manually....

Also i will say if your running locally it has a seperate local cache then the live server. if someone updates a team or if some one clicks update stats on the live server, it is not propagated to your local instance. You have to click update team if a player gets traded. Now on the live server its a bit different because anyone can click update team and everyone will see the updated team on there live server account.... same with your local instance tho if you had multiple users, and clicked update team on your local install the other users also would see the updated team.

Each running web server acts independently, In fact your local install never talks to nbadata.cloud at all, it only requests 3rd party data sources as needed. It is 100% possible for a local instances become out of sync or display incorrect data if the correct buttons haven't been clicked... basically if something is incorrect just click update player or update team.... this is super recent though so it also wasn't in the general season team roster update like 2 weeks ago... I do try to push updates so even when someone downloads the project for the first time most stuff should already be correct.... ~On September 26, 2023, Oubre signed with the Philadelphia 76ers.

Generally speaking if a player has been traded or you want to update something since downloading the project, you must click update stats or update team. Recently i did add a feature where it checks the last game stats for each game you create and compares them to the roster, this gives a eventually correct effect.... To be clear different data has different cache policies and will update differently. For instance there is absolutely no way to get the last game of either team and stats for that game with out calling the api, it has to be live. But all api's have rate limits, and we definitely cant make unlimited requests. Season averages dont tend to change much soo for every game you create they are not updated. You can update any players season average by clicking update stats. Team rosters dont change that much, if a player gets traded just click update team. Team record data changes quite often, win/los record and streak changes with every day that passes same as each teams last game. These all have policies to update as quickly as we can, while attempting to serve the least amount of stale data.

If you create the same game over and over again, its not gona hit the api every time. It will only hit the api for vegas odds if its been 60 seconds since the last cache save. It will only hit the team stats api for win/loss record and streaks a max of 1 time every 5 minutes. It will only ever request a last game 1 time. After we have the last game cached we never need to update that last game because its in the past and docent change. When you create a game we cannot request new stats for every player, its just too many requests, i mean to be honest you can, and then you can make each request take 1 second with time sleep() not hit any rate limits, but you end up with 30-60 second game page loads.... and its just terrible experience. I try to keep a balance, I want all the stats to be up to date, but the api server cant handle the amount of data we are currently using... This lead to creating system that update as needed, manually when the users requests, and also set policies around when data should automatically be updated.

I think it would be a good idea if i add some documentation on how data is updated, how the pickle data cache works.....

68747470733a2f2f692e696d6775722e636f6d2f676437415256692e706e67

I should also have probably picked up your almost certainly talking about a local instal. you can run python3 updateRoster.py This take a bit, it take i think 3 seconds per player with over 600+ players. This also puts extreme load on the api, so please do not use often, if a single player needs to be updated just update a single player. There is absolutely no reason to make 600 requests if you only need 1 player to update. balldontlie.io is a free api rate limited at 1 request per second. If you bypass the rate limit in anyway or request more than 60 api calls within 1 minute the server restarts and will not reply to anyone until its done restarting......