PS3838


NamePS3838 JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/gaetanlefournis/PS3838.git
SummaryA package to interact with the PS3838 API, especially to retrieve odds and bet automatically.
upload_time2024-09-16 09:50:53
maintainerNone
docs_urlNone
authorGaëtan Le Fournis
requires_pythonNone
licenseMIT
keywords ps3838 bet betting odds football soccer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```python
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 : 

![Example of telegram logs](PS3838/_images/image_telegram.png)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gaetanlefournis/PS3838.git",
    "name": "PS3838",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "PS3838, bet, betting, odds, football, soccer",
    "author": "Ga\u00ebtan Le Fournis",
    "author_email": "gaetanlf22@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/e1/8b698d971e4a5bffab81dadaf0958ce9f59116c5283439994eddd9889606/PS3838-0.4.1.tar.gz",
    "platform": null,
    "description": "# BET PS3838\n\n## Introduction\n\n**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).\n\n\n## Package functionalities\n\nThere are two classes in the package called \"PS3838RetrieveOdds\" and \"PS3838AutomatedBets\"\n\n- **PS3838RetrieveOdds** :\n    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.\n    \n        Parameters:\n            - credentials (Dict[str, str]): The credentials to connect to the PS3838 API. \n                Example: {\"username\": \"my_username\", \"password\": \"my_password\"}\n            - list_matches (List[Dict[str, Any]]): A list of matches to retrieve the odds for or to place the bets for.\n                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.\n            - logger_active (bool): A boolean to activate the logger. Default is True.\n            - to_bet (bool): A boolean to know if we want to retrieve the odds or place the bets. Default is False.\n\n- **PS3838RetrieveOdds** :\n    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.\n        \n        Parameters:\n            config (Dict[str, str]): The config to connect to the PS3838 API.\n                Example: {\"username\": \"my_username\", \"password\": \"my_password\"}\n            logger_active (bool): A boolean to activate the logger. Default is True.\n            logger_name (str): The name of the log file. Default is \"PS3838.log\".\n\n    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.\n\n        Parameters:\n            until_date (datetime): The date until which we want to retrieve the matches. Default is None, it retrieves everything in the specified leagues.\n            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.\n\n        Returns:\n            List[List[Dict[str, Any]]]: A list of matches with their corresponding odds.\n                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}}, ...]\n    \n\n- **PS3838AutomatedBets** : \n    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.\n        \n        Parameters:\n            config (Dict[str, str]): The config to connect to the PS3838 API. \n                Example: {\"username\": \"my_username\", \"password\": \"my_password\"}\n            list_matches (List[Dict[str, Any]]): A list of matches to bet on.\n                Example: \n                    [{'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},\n                    {'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}, ...].\n            logger_active (bool): A boolean to activate the logger. Default is True.\n            to_bet (bool): A boolean to know if we really want to bets. Default is False, useful for testing the code.\n\n    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.\n \n        Returns:\n            List[List[Dict[str, Any]]] | None: A list of matches with their corresponding odds if the bets were placed, None otherwise.\n                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}}, ...]\n\n\n## How to use the package\n\nHere is an example of code to use the package\n\n```python\nimport PS3838\n\n# CREDENTIALS PART\nconfig = {'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}}\n\n\n# MATCHES PART\nmatch1 = {\n    'id': 1596236279, \n    'starts': '2024-09-14T19:00:00Z',\n    'home': 'Paris Saint-Germain', \n    'away': 'Brest', \n    'league': 2036, \n    'line_id': 2673340912, \n    'odds': {'home': 1.296, 'away': 8.56, 'draw': 5.91},\n    'prediction': 1,\n    'amount': 5,\n}\nmatch2 = {\n    #league = 61\n    \"league\" : 61,\n    \"team1\" : \"Marseille\",\n    \"team2\" : \"Nice\",\n    \"prediction\" : 1,\n    \"amount\" : 5,\n}\n\n\nmatches = [match1]\n\n\n# BETTING PART\nbetting_object = PS3838.PS3838AutomatedBets(config, list_matches=matches, logger_active=True, to_bet=False)\nmatches_status = betting_object.betting()\nprint(matches_status)\n\n# RETRIEVE PART\nretrieve_object = PS3838.PS3838RetrieveOdds(config, logger_active=True)\nmatches_odds = retrieve_object.retrieving(leagues=[2036])\nprint(matches_odds)\n\n# BANKROLL PART\nbankroll_object = PS3838.PS3838RetrieveBankroll(config, logger_active=True)\nbankroll = bankroll_object.retrieve_bankroll()\nprint(bankroll)\n```\n\n\n## Logger\n\nYou can activate or desactivate the logger with the parameter \"logger_active\" when instantiating.\n- 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\".)\n- If the logger is active and the telegram parameters are missing, then you will receive the logs only on a PS3838.log file.\n- If the logger is not active then you will not receive anything.\n\nHere is an example of what the logger can display on Telegram : \n\n![Example of telegram logs](PS3838/_images/image_telegram.png)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package to interact with the PS3838 API, especially to retrieve odds and bet automatically.",
    "version": "0.4.1",
    "project_urls": {
        "Bug Reports": "https://github.com/gaetanlefournis/PS3838/issues",
        "Homepage": "https://github.com/gaetanlefournis/PS3838.git",
        "Source": "https://github.com/gaetanlefournis/PS3838"
    },
    "split_keywords": [
        "ps3838",
        " bet",
        " betting",
        " odds",
        " football",
        " soccer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75e8ab1b342b12b1bb21360b0de97dc3a60d0a4acedadb2d0176a224c5839410",
                "md5": "90294259b8c7842f8a2f1710f992e734",
                "sha256": "975b5ce500654d2b100bbbdf5d9a3d4efa73cfbf0b5f716aa2bd75cf6d613150"
            },
            "downloads": -1,
            "filename": "PS3838-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90294259b8c7842f8a2f1710f992e734",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 132002,
            "upload_time": "2024-09-16T09:50:49",
            "upload_time_iso_8601": "2024-09-16T09:50:49.052294Z",
            "url": "https://files.pythonhosted.org/packages/75/e8/ab1b342b12b1bb21360b0de97dc3a60d0a4acedadb2d0176a224c5839410/PS3838-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0e18b698d971e4a5bffab81dadaf0958ce9f59116c5283439994eddd9889606",
                "md5": "8ba8fc602641eb347f3b2982511626e9",
                "sha256": "d249ed421feb65f67358fd0af1fe280f3d6e9ca00f9fd6ce4ee8e610f4a6cb24"
            },
            "downloads": -1,
            "filename": "PS3838-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8ba8fc602641eb347f3b2982511626e9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 61178,
            "upload_time": "2024-09-16T09:50:53",
            "upload_time_iso_8601": "2024-09-16T09:50:53.547488Z",
            "url": "https://files.pythonhosted.org/packages/f0/e1/8b698d971e4a5bffab81dadaf0958ce9f59116c5283439994eddd9889606/PS3838-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-16 09:50:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gaetanlefournis",
    "github_project": "PS3838",
    "github_not_found": true,
    "lcname": "ps3838"
}
        
Elapsed time: 0.52328s