Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
namibsun
python
BetBot
Commits
168d902e
Commit
168d902e
authored
Sep 04, 2020
by
Hermann Krumrey
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request
!3
parents
35d7e707
b820cfc7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
7 deletions
+77
-7
CHANGELOG
CHANGELOG
+3
-1
betbot/api/ApiConnection.py
betbot/api/ApiConnection.py
+16
-5
betbot/prediction/RandomPredictor.py
betbot/prediction/RandomPredictor.py
+50
-0
betbot/prediction/__init__.py
betbot/prediction/__init__.py
+2
-0
resources/data/Potential.md
resources/data/Potential.md
+5
-0
version
version
+1
-1
No files found.
CHANGELOG
View file @
168d902e
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
betbot/api/ApiConnection.py
View file @
168d902e
...
...
@@ -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:
Non
e
:return:
True if the login was successfull
e
"""
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
:
...
...
betbot/prediction/RandomPredictor.py
0 → 100644
View file @
168d902e
"""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
betbot/prediction/__init__.py
View file @
168d902e
...
...
@@ -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
]
resources/data/Potential.md
0 → 100644
View file @
168d902e
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
version
View file @
168d902e
0.2.0
\ No newline at end of file
0.3.0
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment