Skip to main content

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

Metadata

Release files for betfairstudio 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for betfairstudio 1.0.0
File Size Uploaded Provenance Actions
betfairstudio-1.0.0.tar.gz 22.4 kB Without provenance Details for betfairstudio-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for betfairstudio 1.0.0
File Interpreter ABI Platform Actions
betfairstudio-1.0.0-py3-none-any.whl Python 3 none any Details for betfairstudio-1.0.0-py3-none-any.whl

Total release size: 51.1 kB

Release files / betfairstudio-1.0.0.tar.gz

Download URL betfairstudio-1.0.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
76a2d45d9c5c45e84dd0449974607f4fbdc6eea333b23abd9bb5ff4739a6187c
BLAKE2b-256 checksum
How to use checksums
e1846fa8a387476e55e47127c5c15a6840920d8666db08e4ed02d89fe777be2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / betfairstudio-1.0.0-py3-none-any.whl

Download URL betfairstudio-1.0.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
596583d68044ca10eb20158544e1420b509b9ff4987303b58598998d46f143f1
BLAKE2b-256 checksum
How to use checksums
b8fd4a70095ceff7cdf51472f16923ee86e36b8de7dba28f23e31a1d68c171d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Security for betfairstudio 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page