Skip to main content

Real-time Forecast Package

PyPI Documentation

A Python package for real-time orchestration of forecasting models.

Installation

pip install "forecast-realtime[models]"

Import your data

Outturns use a long-form DataFrame with date, frequency, variable, value, vintage_date and metric columns. This walkthrough uses the bundled data generator; replace sample_data with your own DataFrame.

import forecast_evaluation as fe
import forecast_realtime as rt

sample_data = rt.generate_synthetic_data(
    N=2,
    first_period="2015-01-31",
    endpoint="2024-12-31",
)
print(sample_data.head().to_string(index=False))
forecast_data = fe.NowcastData(outturns_data=sample_data)

The first five generated outturn rows are:

        date frequency  variable      value vintage_date metric
2015-01-31         M monthly_1 101.577869   2024-01-31 levels
2015-01-31         M monthly_2 101.256092   2024-01-31 levels
2015-02-28         M monthly_1 101.293703   2024-01-31 levels
2015-02-28         M monthly_1  -0.002798   2024-01-31    pop
2015-02-28         M monthly_2  98.456195   2024-01-31 levels

Use an existing model

existing_model = rt.models.ForecastRidge(label="Ridge", cv=5, scale=True)

Add your own model

Subclass ForecastModel and implement _fit() and _forecast(). y and X arrive as pandas DataFrames.

import numpy as np


class MyOLS(rt.ForecastModel):
    """Small OLS model showing the custom-model authoring pattern."""

    def _fit(self, y, X=None, **kwargs):
        # y and X are passed as pandas DataFrames
        if X is None:
            raise ValueError("MyOLS requires X")
        X = X.to_numpy(dtype=float)
        y = y.to_numpy(dtype=float)

        # OLS estimate: beta = (X'X)^-1 X'y
        self.beta = np.linalg.inv(X.T @ X) @ X.T @ y

        return self

    def _forecast(self, steps, X=None, y=None, **kwargs):
        if X is None:
            raise ValueError("MyOLS requires future X")
        # ForecastModel passes the historical and future design rows.
        future_X = X.loc[X.index > self.last_y_fit_date].iloc[:steps]
        return future_X.to_numpy(dtype=float) @ self.beta


custom_model = MyOLS(label="My OLS")

Forecast

Pass one or more models to RealTimeModel, then call forecast():

rt_model = rt.RealTimeModel(
    data=forecast_data,
    models=[existing_model, custom_model],
)

rt_model.forecast(
    y_variables=["quarterly_1"],
    X_variables=["quarterly_2"],
    data_transformation={"quarterly_1": "pop", "quarterly_2": "pop"},
    steps=2,
    X_imputation="last",
    first_vintage="2024-01-31",
    last_vintage="2024-06-30",
)
print(rt_model.data.forecasts.head().to_string(index=False))

Documentation

Data Classification

Bank of England Data Classification: OFFICIAL BLUE

Release files for forecast-realtime 0.5.9

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

Source distribution (sdist)

Source distribution for forecast-realtime 0.5.9
File Size Uploaded
forecast_realtime-0.5.9.tar.gz 204.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for forecast-realtime 0.5.9
File Interpreter ABI Platform
forecast_realtime-0.5.9-py3-none-any.whl Python 3 none any Details

Total release size: 332.8 kB

Release files / forecast_realtime-0.5.9.tar.gz

Download URL forecast_realtime-0.5.9.tar.gz
Size 204.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cc0c16569be721a8241ec108d5647adb25cca8cf02e1e338762da8767b10cb87
BLAKE2b-256 checksum
How to use checksums
14bd7137c15b75ca325459beacd486e7c4f5d79e4bac9b1282fb93b39fa7f1b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / forecast_realtime-0.5.9-py3-none-any.whl

Download URL forecast_realtime-0.5.9-py3-none-any.whl
Size 128.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d408471b232baf051a5058644631795739cfe89d9e47abcef73c04ba5d59324f
BLAKE2b-256 checksum
How to use checksums
c8b242d2d07a8f173bbd8605e4cf3b6b9fdf894b690589ac03c69dda491c2e48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.10

2 release files

This release

0.5.9 This release

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

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