Skip to main content

A library for determining what bets to make.

Project description

moneyball

PyPi

A library for determining what bets to make.

moneyball

Dependencies :globe_with_meridians:

Python 3.11.6:

Raison D'être :thought_balloon:

moneyball was split out of the library sportsball in order to iterate separately on the quantitative strategies and the data powering them. It aims to be an automated way to come up with an optimal betting strategy when supplied with data in a sportsball format.

Architecture :triangular_ruler:

moneyball is an object orientated library. The entities are organised like so:

  • Portfolio: A collection of strategies.
    • Strategy: A method to determine what specific bet to make according.
      • Features: The features extracted from the data.
      • Reducers: The features removed from the data.
      • Trainers: The type of models used for training on the data.
      • Weights: Weight strategies to apply to the data.

Installation :inbox_tray:

This is a python package hosted on pypi, so to install simply run the following command:

pip install moneyball

or install using this local repository:

python setup.py install --old-and-unmanageable

Usage example :eyes:

There are many different ways of using moneyball, but we generally recommend the CLI. This pairs very well with the sister project sportsball.

CLI

The following operations can be run on the CLI:

Train

To train a new strategy:

sportsball --league=nfl - | moneyball test_nfl_strategy train

Portfolio

To develop a portfolio of strategies:

moneyball --strategy=test_nfl_strategy --strategy=test_afl_strategy test_portfolio portfolio

Next

To get a quantitative report on the next bets to place:

moneyball --output=bets.json test_portfolio next

This will result in the following JSON written to stdout:

{
    "bets": [{
        "strategy": "test_nfl_strategy",
        "league": "nfl",
        "kelly": 0.32,
        "weight": 0.1,
        "probability": 0.95,
        "teams": [{
            "name": "giants",
            "probability": 0.1
        }, {
            "name": "dolphins",
            "probability": 0.9
        }],
        "dt": "2025-01-23T16:03:46Z"
    }]
}

Python

To create a portfolio, the following example can be used:

from moneyball import moneyball as mnb

df = ... # Fetch the dataframe from sportsball

moneyball = mnb.Moneyball()
strategy = moneyball.create_strategy(df, "test_strategy")
strategy.fit()
portfolio = ball.create_portfolio([strategy], "test_portfolio")
returns = portfolio.fit()
portfolio.render(returns)

License :memo:

The project is available under the MIT License.

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

moneyball-0.0.194.tar.gz (23.1 kB view details)

Uploaded Source

File details

Details for the file moneyball-0.0.194.tar.gz.

File metadata

  • Download URL: moneyball-0.0.194.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for moneyball-0.0.194.tar.gz
Algorithm Hash digest
SHA256 6b8af9b5bfaf86e32c133b74382ad380c096c13f85289c96dd515f1d820e63f6
MD5 966e267c1c4f7bf80ec91fd480114704
BLAKE2b-256 a9ec5d8e63a7c5b1ec7202670a38b850e32b055fe2663131ed02980725c86f0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page