Commit 168d902e authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'

Develop

See merge request !3
parents 35d7e707 b820cfc7
V 0.3.0:
- Added Random Betting
V 0.2.0:
- Implemented basic framework
- Implemented tipico-quote based predictor
- Implemented API connection
V 0.1.0:
- Project Start
\ No newline at end of file
- Project Start
......@@ -53,18 +53,27 @@ class ApiConnection:
"""
return {"Authorization": "Basic " + self.api_key}
def login(self):
def login(self) -> bool:
"""
Retrieves an API Key using a username and password if no key
has been retrieved yet or if the existing key has expired
:return: None
:return: True if the login was successfulle
"""
if not self.authorized():
self.logger.info("Requesting new API Key")
creds = {"username": self.username, "password": self.password}
data = self.execute_api_call("key", "POST", False, creds)
api_key = data["data"]["api_key"]
self.api_key = b64encode(api_key.encode("utf-8")).decode("utf-8")
if data["status"] != "ok":
self.logger.warning("Login attempt failed")
return False
else:
api_key = data["data"]["api_key"]
encoded = b64encode(api_key.encode("utf-8"))
self.api_key = encoded.decode("utf-8")
return True
else:
return True
def authorized(self) -> bool:
"""
......@@ -116,7 +125,9 @@ class ApiConnection:
:return: The response JSON
"""
if authorization_required and endpoint != "authorize":
self.login()
logged_in = self.login()
if not logged_in:
return {"status": "error"}
extras = {}
if authorization_required:
......
"""LICENSE
Copyright 2020 Hermann Krumrey <hermann@krumreyh.com>
This file is part of betbot.
betbot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
betbot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with betbot. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import random
from typing import List
from betbot.api.Bet import Bet
from betbot.api.Match import Match
from betbot.prediction.Predictor import Predictor
class RandomPredictor(Predictor):
"""
Class that always predicts random results
"""
@classmethod
def name(cls) -> str:
"""
:return: The name of the predictor
"""
return "random"
def predict(self, matches: List[Match]) -> List[Bet]:
"""
Performs the prediction
:param matches: The matches to predict
:return: The predictions as Bet objects
"""
bets = []
for match in matches:
home_goals = random.randint(0, 4)
away_goals = random.randint(0, 4)
bets.append(Bet(match.id, home_goals, away_goals))
return bets
......@@ -20,9 +20,11 @@ LICENSE"""
from typing import Type, List
from betbot.prediction.Predictor import Predictor
from betbot.prediction.DrawPredictor import DrawPredictor
from betbot.prediction.RandomPredictor import RandomPredictor
from betbot.prediction.TipicoOddsPredictor import TipicoOddsPredictor
predictors: List[Type[Predictor]] = [
DrawPredictor,
RandomPredictor,
TipicoOddsPredictor
]
https://www.kaggle.com/hugomathien/soccer
https://www.kaggle.com/stefanoleone992/fifa-20-complete-player-dataset?select=players_20.csv
https://sofifa.com/player/158023
https://kickoff.ai/
https://www.asianentrepreneur.org/how-i-used-machine-learning-to-predict-football-games-for-24-months-straight/
\ No newline at end of file
0.2.0
\ No newline at end of file
0.3.0
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment