Skip to main content

Betfair Exchange horse racing feature collector for odds modeling

Project description

Betfair Studio

Collecteur de features hippiques via l'API Betfair Exchange, orienté modélisation de cotes.

Récupère pour chaque course dans la fenêtre [-20 min, +25 min] :

  • Hippodromes (venues)
  • Métadonnées course (going, météo, type)
  • Chevaux (pedigree, forme, poids, stall)
  • Jockey, trainer, owner
  • Cotes back/lay live (ou delayed selon la clé API)

Les données sont stockées dans un feature store (JSON + Parquet) prêt pour un modèle ML de correction de cotes.

Installation

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Configuration

cp config/settings.example.yaml config/settings.yaml
# Éditer avec vos identifiants Betfair

Voir docs/API_KEY_SETUP.md pour créer une clé API gratuite.

Lancer le collecteur

# Une seule collecte
betfair-collector --once

# Boucle toutes les 5 minutes (défaut)
betfair-collector

# Boucle toutes les 30 secondes (après activation clé Live)
betfair-collector --interval 30

# Filtrer un autre pays
betfair-collector --country GB

Utilisation programmatique

from betfairstudio.config.settings import Settings
from betfairstudio.factory import BetfairStudio
from betfairstudio.ml.odds_predictor import BaselineOddsPredictor

settings = Settings.from_yaml("config/settings.yaml")

with BetfairStudio(settings) as studio:
    snapshot, path = studio.collect_and_store()

    for race in snapshot.races:
        print(f"{race.venue.name}{race.market_name}{race.runner_count} partants")
        for horse in race.runners:
            back = horse.odds.best_back.price if horse.odds and horse.odds.best_back else None
            print(f"  {horse.name} | jockey={horse.jockey.name} | back={back}")

    predictor = BaselineOddsPredictor()
    if snapshot.races:
        preds = predictor.predict_race(snapshot.races[0])
        for p in preds:
            print(p.horse_name, p.predicted_price, p.edge_pct)

Proxy

Trois modes de transport :

Mode Description
direct Connexion directe à Betfair
http_proxy Proxy HTTP/HTTPS classique
relay_proxy Relais applicatif custom

Voir docs/PROXY_SETUP.md.

Structure du feature store

data/feature_store/
├── snapshots/          # JSON complets (webapp)
├── parquet/            # Tables runners (ML)
│   └── runners_cumulative.parquet
└── index/
    ├── latest_races.json    # Liste courses pour UI
    └── latest_snapshot.json

Architecture

Transport (direct | http_proxy | relay_proxy)
    └── SessionManager (auth)
        └── BetfairClient (JSON-RPC)
            └── RaceCollector
                └── FeatureStore (JSON + Parquet)
                    └── OddsPredictor (ML)

Tests

pytest tests/ -v

Prochaines étapes

  • Webapp de visualisation (liste courses → détail chevaux/features/cotes)
  • Modèle ML custom remplaçant BaselineOddsPredictor
  • Intégration Timeform API pour historique complet
  • Passage à la clé Live pour données temps réel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

betfairstudio-1.0.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

betfairstudio-1.0.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file betfairstudio-1.0.0.tar.gz.

File metadata

  • Download URL: betfairstudio-1.0.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for betfairstudio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 76a2d45d9c5c45e84dd0449974607f4fbdc6eea333b23abd9bb5ff4739a6187c
MD5 302bfd89917d37ff9c794204b283ac62
BLAKE2b-256 e1846fa8a387476e55e47127c5c15a6840920d8666db08e4ed02d89fe777be2a

See more details on using hashes here.

File details

Details for the file betfairstudio-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: betfairstudio-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for betfairstudio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 596583d68044ca10eb20158544e1420b509b9ff4987303b58598998d46f143f1
MD5 147c21199ae52a5ef6510add9a74e037
BLAKE2b-256 b8fd4a70095ceff7cdf51472f16923ee86e36b8de7dba28f23e31a1d68c171d1

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