Skip to main content

Real-time Forecast Package

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

The main object, RealTimeModel, combines a ForecastData object (from the forecast_evaluation package) with one or more ForecastModel objects. ForecastModel is an abstract base class with _fit(), _forecast() and an optional _forecast_decomp() method. All built-in models inherit from it, and you can subclass it to wrap any Python (or R, MATLAB, or Julia) forecasting model.

Installation

pip install forecast_realtime[models]

Quick demo

import forecast_evaluation as fe
import forecast_realtime as rt

forecast_data = fe.ForecastData(load_fer=True)

ridge = rt.models.ForecastRidge(label="Ridge", cv=5, scale=True)
lasso = rt.models.ForecastLasso(label="LASSO", cv=5, scale=True)

rt_model = rt.RealTimeModel(
    data=forecast_data,
    models=[ridge, lasso],
)

rt_model.forecast(
    y_variables=["cpisa"],
    X_variables=["gdpkp"],
    data_transformation={"cpisa": "pop", "gdpkp": "pop"},
    steps=12,
    y_lags=4,
    X_imputation="last",
)

# Optional interactive dashboard:
# rt_model.data.run_dashboard()

Marimo notebook

Install the notebook and model dependencies from the repository root:

pip install -e ".[models,notebooks]"

Open the demo as an editable notebook with visible code cells and outputs:

marimo edit notebooks/demo_models.py

Add your own model

Subclass ForecastModel and implement _fit() and _forecast() (plus _forecast_decomp() if you want news decompositions). y and X arrive as pandas DataFrames, and the base class handles validation, lags, dummies and forecast dates.

import numpy as np
import pandas as pd

from forecast_realtime import ForecastModel


class MyOLS(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

Pass it straight to RealTimeModel:

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

Documentation

Data Classification

Bank of England Data Classification: OFFICIAL BLUE

Release files for forecast-realtime 0.5.3

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.3
File Size Uploaded
forecast_realtime-0.5.3.tar.gz 165.8 kB Details

Built distribution (wheel)

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

Total release size: 282.4 kB

Release files / forecast_realtime-0.5.3.tar.gz

Download URL forecast_realtime-0.5.3.tar.gz
Size 165.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2f5b35cc484adeed783a46ec91914fdd130db88677630ae65ea39d38b06e9f5a
BLAKE2b-256 checksum
How to use checksums
e6691aa3e2e10186b03875fef77f11ac867256d2d558dbcd8fff831cae1a3584
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 Aug 28, 2026.

Transparency log

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

Download URL forecast_realtime-0.5.3-py3-none-any.whl
Size 116.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af07d0c930b68e15c2dabddc7337b594cc39e588504c7ca677cf9cb58291d588
BLAKE2b-256 checksum
How to use checksums
61316e89e62774081799df9159c16bdad55f57bc17ab8a45ebfcc528405cf67b
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 Aug 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.10

2 release files

0.5.9

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

This release

0.5.3 This release

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