Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2020 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of betbot.
6betbot is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11betbot is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with betbot. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20from typing import List
21from betbot.api.Bet import Bet
22from betbot.api.Match import Match
23from betbot.prediction.Predictor import Predictor
26class LeagueTablePredictor(Predictor):
27 """
28 Class that always 2:1 for the team higher up in the league table
29 """
31 @classmethod
32 def name(cls) -> str:
33 """
34 :return: The name of the predictor
35 """
36 return "league-table"
38 def predict(self, matches: List[Match]) -> List[Bet]:
39 """
40 Performs the prediction
41 :param matches: The matches to predict
42 :return: The predictions as Bet objects
43 """
44 league_table = self.api.get_league_table(self.league, self.season)
45 bets = []
46 for match in matches:
47 home_team_index = league_table.index(match.home_team)
48 away_team_index = league_table.index(match.away_team)
49 if home_team_index < away_team_index:
50 home_goals, away_goals = 2, 1
51 else:
52 home_goals, away_goals = 1, 2
53 bets.append(Bet(match, home_goals, away_goals))
54 return bets