A package to interact with the PS3838 API, especially to retrieve odds and bet automatically.
Project description
BET PS3838
Introduction
BET PS3838 This project aims to bet automatically on different odds available on PS3838. It is part of a bigger secret project, but can be used by anyone who wants to place some bets, or retrieve some football odds (indeed, only football for the moment).
Package functionalities
There are two classes in the package called "PS3838RetrieveOdds" and "PS3838AutomatedBets"
-
PS3838RetrieveOdds : This class is used to retrieve the odds for a list of matches or to place bets on the PS3838 API. It also uses a CustomLogger to log the information.
Parameters: - credentials (Dict[str, str]): The credentials to connect to the PS3838 API. Example: {"username": "my_username", "password": "my_password"} - list_matches (List[Dict[str, Any]]): A list of matches to retrieve the odds for or to place the bets for. Example: [{"league" : 2036, "team1" : "Montpellier", "team2" : "Paris Saint-Germain", "date" : datetime(2024, 8, 17, 17, 0, 0), "prediction" : 2, "amount" : 5, "odd_min" : 1.05}, ...]. Note that the parameters "prediction", "amount" and "odd_min" are optional and only used when placing bets. - logger_active (bool): A boolean to activate the logger. Default is True. - to_bet (bool): A boolean to know if we want to retrieve the odds or place the bets. Default is False.
-
PS3838RetrieveOdds : This class is used to retrieve the odds from the PS3838 API. It uses the Retrieve class to connect to the API and retrieve the odds for each match. It also uses a CustomLogger to log the information.
Parameters: config (Dict[str, str]): The config to connect to the PS3838 API. Example: {"username": "my_username", "password": "my_password"} logger_active (bool): A boolean to activate the logger. Default is True. logger_name (str): The name of the log file. Default is "PS3838.log".
The main function in this class is "retrieving()". This function retrieves the odds for all the matches until a given date and for a given list of leagues.
Parameters: until_date (datetime): The date until which we want to retrieve the matches. Default is None, it retrieves everything in the specified leagues. leagues (List[int]): A list of leagues for which we want to retrieve the matches. Default is None, it retrieves every league until the date specified. Returns: List[List[Dict[str, Any]]]: A list of matches with their corresponding odds. Example: [{'id': 1595460299, 'starts': '2024-08-23T18:45:00Z', 'home': 'Paris Saint-Germain', 'away': 'Montpellier HSC', 'league': 2036, 'line_id': 2650184231, 'odds': {'home': 1.309, 'draw': 6.14, 'away': 8.47}}, ...]
-
PS3838AutomatedBets : This class is used to place bets on the PS3838 API. It uses the Bet classes to connect to the API and place the bets. It also uses a CustomLogger to log the information.
Parameters: config (Dict[str, str]): The config to connect to the PS3838 API. Example: {"username": "my_username", "password": "my_password"} list_matches (List[Dict[str, Any]]): A list of matches to bet on. Example: [{'id': 1596465583, 'starts': '2024-09-04T17:45:00Z', 'home': 'Resende FC', 'away': 'Artsul', 'league': 216059, 'line_id': 2673459336, 'odds': {'Team1': 2.05, 'Team2': 3.1, 'Draw': 3.25}, 'prediction': 1, 'amount': 5}, {'id': 1596465586, 'starts': '2024-09-04T17:45:00Z', 'home': 'Fluminense', 'away': 'AF Perolas Negras', 'league': 216059, 'line_id': 2673462355, 'odds': {'Team1': 1.159, 'Team2': 11.83, 'Draw': 5.83}, 'prediction': 0, 'amount': 5}, ...]. logger_active (bool): A boolean to activate the logger. Default is True. to_bet (bool): A boolean to know if we really want to bets. Default is False, useful for testing the code.
The main function in this class is "betting()". This function places bets on the PS3838 API for a given list of matches, if the bets are not already placed and if the maintenance is not in progress.
Returns: List[List[Dict[str, Any]]] | None: A list of matches with their corresponding odds if the bets were placed, None otherwise. Example: [{'id': 1595460299, 'starts': '2024-08-23T18:45:00Z', 'home': 'Paris Saint-Germain', 'away': 'Montpellier HSC', 'league': 2036, 'line_id': 2650184231, 'odds': {'home': 1.309, 'draw': 6.14, 'away': 8.47}}, ...]
How to use the package
Here is an example of code to use the package
import PS3838
# CREDENTIALS PART
config = {'username': 'gagou', 'telegram': {'token': 'YOUR_TELEGRAM_TOKEN', 'chat_id': 'YOUR_TELEGRAM_CHAT_ID'}, 'ps3838': {'username': 'YOUR_USERNAME_PS3838', 'password': 'YOUR_PASSWORD_ps3838'}, 'db': {'db_bets': {'root_password': 'ROOT_PASSWORD', 'host': 'localhost', 'name': 'bet_db', 'user': 'user', 'password': 'PASSWORD'}, 'db_preds': {'host': 'IP_ADDRESS', 'port': '5432', 'name': 'football', 'user': 'postgres', 'password': 'PASSWORD'}}, 'strategy': {'leagues': [2036, 4867], 'criterion': 'kelly', 'min_amount': 5}}
# MATCHES PART
match1 = {
'id': 1596236279,
'starts': '2024-09-14T19:00:00Z',
'home': 'Paris Saint-Germain',
'away': 'Brest',
'league': 2036,
'line_id': 2673340912,
'odds': {'home': 1.296, 'away': 8.56, 'draw': 5.91},
'prediction': 1,
'amount': 5,
}
match2 = {
#league = 61
"league" : 61,
"team1" : "Marseille",
"team2" : "Nice",
"prediction" : 1,
"amount" : 5,
}
matches = [match1]
# BETTING PART
betting_object = PS3838.PS3838AutomatedBets(config, list_matches=matches, logger_active=True, to_bet=False)
matches_status = betting_object.betting()
print(matches_status)
# RETRIEVE PART
retrieve_object = PS3838.PS3838RetrieveOdds(config, logger_active=True)
matches_odds = retrieve_object.retrieving(leagues=[2036])
print(matches_odds)
# BANKROLL PART
bankroll_object = PS3838.PS3838RetrieveBankroll(config, logger_active=True)
bankroll = bankroll_object.retrieve_bankroll()
print(bankroll)
Logger
You can activate or desactivate the logger with the parameter "logger_active" when instantiating.
- If the logger is active and a telegram token and chat id are provided in the config dict, then you will receive the logs on your telegram chatbot and on a PS3838.log file. (On telegram there are only the logs up to "INFO", not "DEBUG".)
- If the logger is active and the telegram parameters are missing, then you will receive the logs only on a PS3838.log file.
- If the logger is not active then you will not receive anything.
Here is an example of what the logger can display on Telegram :
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PS3838-0.4.2.tar.gz
.
File metadata
- Download URL: PS3838-0.4.2.tar.gz
- Upload date:
- Size: 60.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b53c8a57e3b9ceb324bc9ecd591587e975348e61d952b847a3f69c1e9f1e58f |
|
MD5 | 3de58f9f083f6476c199dc6aead3e341 |
|
BLAKE2b-256 | 9ad356b576a1f10bbf0f50cbfed4fcc226f1ecf7634d3d4dce000dc9385cf407 |
File details
Details for the file PS3838-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: PS3838-0.4.2-py3-none-any.whl
- Upload date:
- Size: 132.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb25264549d505485f315c38c493be9f81103c75589d6249c01e688671fbdf7c |
|
MD5 | 6a11e64a93d0cd00baf0b8949169a363 |
|
BLAKE2b-256 | 226b881dda52df0e855645a3df89d932840177212cb3934f5560029fd0c70c77 |