betting-env


Namebetting-env JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/MeherKharbachi/betting_env
SummaryCreate a custom GYM environment to simulate trading strategy.
upload_time2023-03-10 09:37:55
maintainer
docs_urlNone
authorMeherKharbachi
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.
            betting_env
================

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

``` python
from IPython.display import HTML
import pandas as pd

from betting_env.config.localconfig import CONFIG,DB_HOSTS
from betting_env.utils.data_extractor import data_aggregator
from betting_env.betting_env import BettingEnv
```

## Install

``` sh
pip install betting_env
```

## 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.

## 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 2 main markets: `1X2`
(home/draw/away) and `Asian handicap` (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 5 possible selections `home team win`, `away team win`,
or `draw` (`1X2` case) or `home` or `away` (`Asian handicap`) 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(
    db_hosts=DB_HOSTS, config=CONFIG, db_host="public_atlas", limit=None
)
```

### 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

HTML('<img src="./images/img_1.gif">')
```

<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

HTML('<img src="./images/img_2.gif">')
```

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MeherKharbachi/betting_env",
    "name": "betting-env",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "notebook python gym reinforcement-learning football",
    "author": "MeherKharbachi",
    "author_email": "meher@cortexya.com",
    "download_url": "https://files.pythonhosted.org/packages/77/3b/8ca43248db7f477578d245ff76556746f3ee48ac86925db3af4c7f6b8a3b/betting_env-0.1.0.tar.gz",
    "platform": null,
    "description": "betting_env\n================\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n``` python\nfrom IPython.display import HTML\nimport pandas as pd\n\nfrom betting_env.config.localconfig import CONFIG,DB_HOSTS\nfrom betting_env.utils.data_extractor import data_aggregator\nfrom betting_env.betting_env import BettingEnv\n```\n\n## Install\n\n``` sh\npip install betting_env\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\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 2 main markets: `1X2`\n(home/draw/away) and `Asian handicap` (we focus on the even line) and is\nonly allowed to place a `small`, `medium`, or `big` stake on *one and\nonly one* of the 5 possible selections `home team win`, `away team win`,\nor `draw` (`1X2` case) or `home` or `away` (`Asian handicap`) or skip\nthe betting opportunity. At each step, the punter is presented with some\ninformation about a game and the associated betting opportunities. If he\ndecides to bet, he receives a *reward* that could be `positive` (profit)\nor `negative` (loss of his stake). His balance is then updated\naccordingly and he moves to the next step i.e next game. An episode ends\nwhen the punter goes bankrupt (Balance \\<= 0) or if no more betting\nopportunities are available.\n\n### Load games\n\n``` python\nfixtures = data_aggregator(\n    db_hosts=DB_HOSTS, config=CONFIG, db_host=\"public_atlas\", limit=None\n)\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\nHTML('<img src=\"./images/img_1.gif\">')\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\nHTML('<img src=\"./images/img_2.gif\">')\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 trading strategy.",
    "version": "0.1.0",
    "split_keywords": [
        "notebook",
        "python",
        "gym",
        "reinforcement-learning",
        "football"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7842cc7fc6a6bd30c5720f86a8603093e8efe00352cfa13f5f54e2343d9829f3",
                "md5": "6cecae79d657832fcc005c9042881d8b",
                "sha256": "55341020a602865ad8a0898c0e97ca6e4d04366a697da44e8abda14d305e5d92"
            },
            "downloads": -1,
            "filename": "betting_env-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cecae79d657832fcc005c9042881d8b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 24219,
            "upload_time": "2023-03-10T09:37:53",
            "upload_time_iso_8601": "2023-03-10T09:37:53.660918Z",
            "url": "https://files.pythonhosted.org/packages/78/42/cc7fc6a6bd30c5720f86a8603093e8efe00352cfa13f5f54e2343d9829f3/betting_env-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "773b8ca43248db7f477578d245ff76556746f3ee48ac86925db3af4c7f6b8a3b",
                "md5": "f3d02133f8b2f8de48e5faaa31a2eec6",
                "sha256": "f64da7f91a579fece1a17130cdb5c3eedb367c2851716e61531383bfcecda8fa"
            },
            "downloads": -1,
            "filename": "betting_env-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f3d02133f8b2f8de48e5faaa31a2eec6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 22532,
            "upload_time": "2023-03-10T09:37:55",
            "upload_time_iso_8601": "2023-03-10T09:37:55.694714Z",
            "url": "https://files.pythonhosted.org/packages/77/3b/8ca43248db7f477578d245ff76556746f3ee48ac86925db3af4c7f6b8a3b/betting_env-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-10 09:37:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "MeherKharbachi",
    "github_project": "betting_env",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "betting-env"
}
        
Elapsed time: 0.05514s