fastbet


Namefastbet JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/real-analytics-rd/fastbet
SummaryCreate a custom gym environment to simulate simple betting strategy.
upload_time2023-03-30 13:19:12
maintainer
docs_urlNone
authorTarak Kharrat and Meher Kharbachi
requires_python>=3.9
licenseApache Software License 2.0
keywords notebook python gym reinforcement-learning football
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            `fastbet`
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
from IPython.display import HTML

import pandas as pd

from fastbet.config.mongo import mongo_init
from fastbet.datastructure.data_extractor import data_aggregator
from fastbet.environment import BettingEnv
```

## Install

``` sh
pip install fastbet
```

## Config

In order to connect to the `mongo` database we require some connection
parameters defined in `toml` format and should be read when the library
is loaded. The package will look first under `/secrets/config.toml` or
in the environment variable `BETTING_ENV_CONFIG`. An example of `config`
file is provided with the package and will be used by default. It is the
user’s responsibility to make sure this file is saved at the right
location if you want to use your own.

Let’s start by registering the connection to the mongo database:

``` python
mongo_init(db_host="public_atlas")
```

## Simplified betting environment

The punter starts with `$N` (N\>0) in his Bank account and can use them
to place bets on several `football` games.

He is offered the option to bet on the 3 main markets: `1X2`
(home/draw/away), `Asian handicap` and `Total(Over/Under)` (we focus on
the even line) and is only allowed to place a `small`, `medium`, or
`big` stake on *one and only one* of the 7 possible selections
`home team win`, `away team win`, or `draw` (`1X2` case) or `home` or
`away` (`Asian handicap` and `Total`) or skip the betting opportunity.
At each step, the punter is presented with some information about a game
and the associated betting opportunities. If he decides to bet, he
receives a *reward* that could be `positive` (profit) or `negative`
(loss of his stake). His balance is then updated accordingly and he
moves to the next step i.e next game. An episode ends when the punter
goes bankrupt (Balance \<= 0) or if no more betting opportunities are
available.

### Load games

``` python
fixtures = data_aggregator(limit=10)
```

### Init environment

``` python
env = BettingEnv(fixtures)
max_steps_limit = fixtures.shape[0]
```

### Playing random choices

``` python
# Init RL env.
env.reset()

# Init done Flag to False.
done = False
# Init loop counter.
i = 0
# Stops when it is done or when we have bet on all provided games.
while not done and i < max_steps_limit:
    # Make a step.
    obs, reward, done, info = env.step(env.action_space.sample())
    # Increment counter.
    i = i + 1
```

<img src="./images/img_1.gif">

### Playing Medium Stake on Home Team Win (1X2)

``` python
# Init RL env.
env.reset()
# Init done Flag to False.
done = False
# Init loop counter.
i = 0
# Stops when it is done or when we have bet on all provided games.
while not done and i < max_steps_limit:
    # Make a step.
    obs, reward, done, info = env.step(2)
    # Increment counter.
    i = i + 1
```

<img src="./images/img_2.gif">

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/real-analytics-rd/fastbet",
    "name": "fastbet",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "notebook python gym reinforcement-learning football",
    "author": "Tarak Kharrat and Meher Kharbachi",
    "author_email": "tarak@realanalytics.co.uk",
    "download_url": "https://files.pythonhosted.org/packages/9d/fd/edc1e31a51e123e1c4338fce258c53e230f20c010800b49a3008958ef3a3/fastbet-0.2.3.tar.gz",
    "platform": null,
    "description": "`fastbet`\n================\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n``` python\nfrom IPython.display import HTML\n\nimport pandas as pd\n\nfrom fastbet.config.mongo import mongo_init\nfrom fastbet.datastructure.data_extractor import data_aggregator\nfrom fastbet.environment import BettingEnv\n```\n\n## Install\n\n``` sh\npip install fastbet\n```\n\n## Config\n\nIn order to connect to the `mongo` database we require some connection\nparameters defined in `toml` format and should be read when the library\nis loaded. The package will look first under `/secrets/config.toml` or\nin the environment variable `BETTING_ENV_CONFIG`. An example of `config`\nfile is provided with the package and will be used by default. It is the\nuser\u2019s responsibility to make sure this file is saved at the right\nlocation if you want to use your own.\n\nLet\u2019s start by registering the connection to the mongo database:\n\n``` python\nmongo_init(db_host=\"public_atlas\")\n```\n\n## Simplified betting environment\n\nThe punter starts with `$N` (N\\>0) in his Bank account and can use them\nto place bets on several `football` games.\n\nHe is offered the option to bet on the 3 main markets: `1X2`\n(home/draw/away), `Asian handicap` and `Total(Over/Under)` (we focus on\nthe even line) and is only allowed to place a `small`, `medium`, or\n`big` stake on *one and only one* of the 7 possible selections\n`home team win`, `away team win`, or `draw` (`1X2` case) or `home` or\n`away` (`Asian handicap` and `Total`) or skip the betting opportunity.\nAt each step, the punter is presented with some information about a game\nand the associated betting opportunities. If he decides to bet, he\nreceives a *reward* that could be `positive` (profit) or `negative`\n(loss of his stake). His balance is then updated accordingly and he\nmoves to the next step i.e next game. An episode ends when the punter\ngoes bankrupt (Balance \\<= 0) or if no more betting opportunities are\navailable.\n\n### Load games\n\n``` python\nfixtures = data_aggregator(limit=10)\n```\n\n### Init environment\n\n``` python\nenv = BettingEnv(fixtures)\nmax_steps_limit = fixtures.shape[0]\n```\n\n### Playing random choices\n\n``` python\n# Init RL env.\nenv.reset()\n\n# Init done Flag to False.\ndone = False\n# Init loop counter.\ni = 0\n# Stops when it is done or when we have bet on all provided games.\nwhile not done and i < max_steps_limit:\n    # Make a step.\n    obs, reward, done, info = env.step(env.action_space.sample())\n    # Increment counter.\n    i = i + 1\n```\n\n<img src=\"./images/img_1.gif\">\n\n### Playing Medium Stake on Home Team Win (1X2)\n\n``` python\n# Init RL env.\nenv.reset()\n# Init done Flag to False.\ndone = False\n# Init loop counter.\ni = 0\n# Stops when it is done or when we have bet on all provided games.\nwhile not done and i < max_steps_limit:\n    # Make a step.\n    obs, reward, done, info = env.step(2)\n    # Increment counter.\n    i = i + 1\n```\n\n<img src=\"./images/img_2.gif\">\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Create a custom gym environment to simulate simple betting strategy.",
    "version": "0.2.3",
    "split_keywords": [
        "notebook",
        "python",
        "gym",
        "reinforcement-learning",
        "football"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f52067539f2a9685414b79bd4675ef895f19de58016f21397f0bc64498830a4",
                "md5": "4a47e759fb46b73f52cd048e0a0db670",
                "sha256": "a714b8130cfb1fa52380e0250927404131a08030e8e2704812dca0fe4fac9a50"
            },
            "downloads": -1,
            "filename": "fastbet-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4a47e759fb46b73f52cd048e0a0db670",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 24525,
            "upload_time": "2023-03-30T13:19:09",
            "upload_time_iso_8601": "2023-03-30T13:19:09.890668Z",
            "url": "https://files.pythonhosted.org/packages/9f/52/067539f2a9685414b79bd4675ef895f19de58016f21397f0bc64498830a4/fastbet-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dfdedc1e31a51e123e1c4338fce258c53e230f20c010800b49a3008958ef3a3",
                "md5": "e3f04523396439ec2b3c0d820430d244",
                "sha256": "3652cc7e24e106aaee8a0374ebe571daf44641c3cc2ac504935ed1cdd0bf9626"
            },
            "downloads": -1,
            "filename": "fastbet-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e3f04523396439ec2b3c0d820430d244",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23108,
            "upload_time": "2023-03-30T13:19:12",
            "upload_time_iso_8601": "2023-03-30T13:19:12.156268Z",
            "url": "https://files.pythonhosted.org/packages/9d/fd/edc1e31a51e123e1c4338fce258c53e230f20c010800b49a3008958ef3a3/fastbet-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-30 13:19:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "real-analytics-rd",
    "github_project": "fastbet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastbet"
}
        
Elapsed time: 0.05410s