BacktestPipeline#

class openstef_beam.backtesting.BacktestPipeline(config: BacktestConfig, forecaster: BacktestForecasterMixin) None[source]#

Bases: object

Pipeline for conducting realistic backtesting of energy forecasting models.

This class orchestrates the backtesting process by simulating the operational environment where forecasts are generated at regular intervals with limited historical data availability. It supports both single and batch prediction modes and handles periodic model retraining.

Variables:
  • config – Configuration parameters for the backtesting process.

  • forecaster – The forecasting model implementing either BacktestForecasterMixin or BacktestBatchForecasterMixin interface.

  • start – Start datetime for the backtesting period.

  • end – End datetime for the backtesting period.

Note

The pipeline ensures temporal consistency by preventing data leakage and respecting the operational constraints that would exist in a real-time forecasting system.

Parameters:
start: datetime#
end: datetime#
__init__(config: BacktestConfig, forecaster: BacktestForecasterMixin) None[source]#

Initialize the backtesting pipeline.

Parameters:
  • config (BacktestConfig) – Backtesting configuration including prediction and training intervals.

  • forecaster (BacktestForecasterMixin) – Model implementing the required forecasting interface.

  • config

  • forecaster

Raises:

ValueError – If the prediction sample intervals don’t match between config and forecaster.

config: BacktestConfig#
forecaster: BacktestForecasterMixin#
run(ground_truth: VersionedTimeSeriesDataset, predictors: VersionedTimeSeriesDataset, start: datetime | None, end: datetime | None, *, show_progress: bool = True) TimeSeriesDataset[source]#

Execute the backtesting simulation and return predictions.

Runs the complete backtesting process by generating events, processing training and prediction operations in chronological order, and collecting all predictions into a single versioned dataset.

Parameters:
  • ground_truth (VersionedTimeSeriesDataset) – Historical target values with timestamps.

  • predictors (VersionedTimeSeriesDataset) – Feature data for model predictions.

  • start (datetime | None) – Start datetime for backtesting. Uses data minimum if None.

  • end (datetime | None) – End datetime for backtesting. Uses data maximum if None.

  • show_progress (bool) – Whether to display progress bar during execution.

  • ground_truth

  • predictors

  • start

  • end

  • show_progress

Returns:

VersionedTimeSeriesDataset containing all predictions with timestamps and availability information. Empty dataset if no predictions made.

Return type:

TimeSeriesDataset