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.279752   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.8

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.8
File Size Uploaded
forecast_realtime-0.5.8.tar.gz 201.7 kB Details

Built distribution (wheel)

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

Total release size: 328.6 kB

Release files / forecast_realtime-0.5.8.tar.gz

Download URL forecast_realtime-0.5.8.tar.gz
Size 201.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0889c8fbdabb62abac9f4269fe6f3d0a4296d010655219db1bf7da1305b8ac19
BLAKE2b-256 checksum
How to use checksums
5498ec3c2c37b6c4a4662799a9c620302d87be8857fe6038e186098d7b615ab9
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 10, 2026.

Transparency log

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

Download URL forecast_realtime-0.5.8-py3-none-any.whl
Size 127.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be633f0f622dc9fed2516e820d0ab9fc5a5065dba623bf735129f4cbd1b2b9c4
BLAKE2b-256 checksum
How to use checksums
c2eadbe06c6fbb0169a9060f1adf7953327a8d215af3e686af44d7406d6dd865
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 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.10

2 release files

0.5.9

2 release files

This release

0.5.8 This release

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