Skip to main content

A Python library for managing and analyzing macroeconomic time series data with vintage awareness.

Project description

MacroTrace

PyPI version Python versions License: GPL-3.0-or-later CI Docs

MacroTrace is a Python library for collecting, storing, and analyzing macroeconomic time-series vintages. It is designed for research workflows where the revision history matters just as much as the latest published value.

Documentation: https://john-ramsey.github.io/macrotrace/

Instead of treating a series as a single final dataset, MacroTrace helps you work with the sequence of releases that were available in real time. This makes it easier to study data revisions, reproduce historical analyses, and compare what was known at different publication dates.

Features

  • Fetch vintage-aware macroeconomic time series from FRED and ONS
  • Store releases locally in SQLite for reproducible, offline-friendly workflows
  • Retrieve series as they were known on a specific date with as_of(...)
  • Filter both vintage windows and data windows when loading a series
  • Export to pandas DataFrames and Darts TimeSeries objects
  • Plot vintages and revision comparisons with built-in Plotly tooling

Installation

Install the package from PyPI:

pip install macrotrace

Install the optional ONS Textual interface:

pip install "macrotrace[ons-tui]"

Requirements

  • Python 3.11+
  • A FRED API key for FRED-backed series

Set your FRED API key before loading FRED series:

export FRED_API_KEY="your_api_key_here"

Quick Start

from macrotrace import MTTimeSeries

payems = MTTimeSeries(
    dataset_id="PAYEMS",
    source="FRED",
)

print(payems)

july_2020 = payems.as_of("2020-07-15")
df = july_2020.to_dataframe()

MacroTrace stores fetched releases in a local SQLite database named MacroTrace.db, making repeated loads faster and keeping vintage histories available for later analysis.

For multi-dimensional datasets such as ONS releases, provide a series_key to select a specific slice of the dataset:

from macrotrace import MTTimeSeries

gdp = MTTimeSeries(
    dataset_id="gdp-to-four-decimal-places",
    source="ONS",
    series_key={
        "geography": "K02000001",
        "unofficialstandardindustrialclassification": "A--T",
    },
)

Command-Line Tools

MacroTrace includes command-line tools for exploring ONS datasets:

macrotrace ons explorer

If you installed the optional TUI extra, you can also run:

macrotrace ons tui

Development

For local development, we use uv for dependency management and environment execution.

Install the project with the development, docs, and optional TUI dependencies:

uv sync --extra ons-tui --group dev --group docs

Run tests inside the managed environment with:

uv run pytest

Code formatting is handled with black:

uv run black .

Project Status

MacroTrace is under active development as part of a PhD research project on macroeconomic data revisions.

License

MacroTrace is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macrotrace-0.1.0rc1.tar.gz (441.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macrotrace-0.1.0rc1-py3-none-any.whl (102.3 kB view details)

Uploaded Python 3

File details

Details for the file macrotrace-0.1.0rc1.tar.gz.

File metadata

  • Download URL: macrotrace-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 441.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for macrotrace-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 9be8aee6459e1986fcb8e8b645b4efcc248cb22174b769097737e9080facf14f
MD5 8fe6b6db55d9937180683c1129052e7d
BLAKE2b-256 e690fa5e8269f3f4183a2759f6b27e0ace34e3ffbd4556eb4f641a9db75c953e

See more details on using hashes here.

Provenance

The following attestation bundles were made for macrotrace-0.1.0rc1.tar.gz:

Publisher: release.yml on john-ramsey/macrotrace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file macrotrace-0.1.0rc1-py3-none-any.whl.

File metadata

  • Download URL: macrotrace-0.1.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 102.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for macrotrace-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 34f308d1828c464a2c6658afed6ad601e902f60d3659496805b086a54fcef3e4
MD5 8f632029e86f49e31bbae6a56edc9913
BLAKE2b-256 83bc87bfed4e75a719f443c58f380c8e257157bc870d1b814c9c495bd774b5af

See more details on using hashes here.

Provenance

The following attestation bundles were made for macrotrace-0.1.0rc1-py3-none-any.whl:

Publisher: release.yml on john-ramsey/macrotrace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page