slickbet.backtest¶
Backtesting for evaluating prediction accuracy against historical data.
Runs the betting model on past matches (simulating pre-match knowledge),
compares predictions to actual outcomes, and reports win / double-chance
accuracy metrics via BacktestResults and format_backtest_report.
Classes¶
Aggregated results from a backtest run. |
|
Backtester for evaluating betting model against historical data. |
|
Result of a single prediction compared to actual outcome. |
Functions¶
|
Generate a formatted report of backtest results. |
Module Contents¶
- class slickbet.backtest.BacktestResults[source]¶
Aggregated results from a backtest run.
- property away_predictions: list[PredictionResult]¶
Predictions where we bet on away team.
- property best_double_chance_accuracy: float¶
Accuracy when following the recommended double chance bet.
- by_probability_threshold(threshold: float) BacktestResults[source]¶
Filter results by minimum probability threshold.
- Parameters:
threshold (float) – Minimum prediction probability (inclusive).
- Returns:
BacktestResults – New results object with filtered predictions.
- from_date: datetime.datetime | None = None¶
- property high_confidence_accuracy_excl_draws: float¶
Accuracy for high confidence predictions, excluding draws.
- property high_confidence_results: list[PredictionResult]¶
Predictions with confidence > 0.3.
- property high_probability_accuracy_excl_draws: float¶
Accuracy for high probability predictions (>60%), excluding draws.
- property high_probability_results: list[PredictionResult]¶
Predictions with probability > 60%.
- property home_predictions: list[PredictionResult]¶
Predictions where we bet on home team.
- property low_draw_risk_results: list[PredictionResult]¶
Predictions where draw risk < 30%.
- results: list[PredictionResult] = []¶
- to_date: datetime.datetime | None = None¶
- class slickbet.backtest.Backtester(client: slickbet.api.LivescoreClient | None = None, model: slickbet.model.BettingModel | None = None, cache_dir: str | pathlib.Path | None = None, cache_only: bool = False)[source]¶
Backtester for evaluating betting model against historical data.
Examples
>>> backtester = Backtester() >>> results = backtester.run( ... competition_id="1", # Premier League ... weeks=4, ... ) >>> print(f"Accuracy: {results.accuracy:.1%}")
- BUNDESLIGA = '1'¶
- LA_LIGA = '3'¶
- LIGUE_1 = '5'¶
- PREMIER_LEAGUE = '2'¶
- SERIE_A = '4'¶
- model¶
- run(competition_id: str = '1', weeks: int = 4, from_date: datetime.datetime | None = None, to_date: datetime.datetime | None = None, min_probability: float = 0.0, verbose: bool = True, debug: bool = False) BacktestResults[source]¶
Run backtest on historical data.
- Parameters:
competition_id (str, optional) – Competition ID to backtest
weeks (int, optional) – Number of weeks of history (if from_date not specified)
from_date (datetime or None, optional) – Start date for historical data
to_date (datetime or None, optional) – End date for historical data (defaults to today)
min_probability (float, optional) – Minimum probability threshold for predictions
verbose (bool, optional) – Print progress information
debug (bool, optional) – Print detailed match-by-match predictions and results
- Returns:
BacktestResults – BacktestResults with all predictions and accuracy metrics
- class slickbet.backtest.PredictionResult[source]¶
Result of a single prediction compared to actual outcome.
- property best_double_chance_correct: bool¶
Whether the recommended double chance bet would have won.
- prediction: slickbet.model.BetPrediction¶
- slickbet.backtest.format_backtest_report(results: BacktestResults) str[source]¶
Generate a formatted report of backtest results.
- Parameters:
results (BacktestResults) – Aggregated backtest results.
- Returns:
str – Multi-line human-readable report.