--- license: other language: - en pretty_name: Macro Indicators โ€” Vintage / PIT (FRED-style) tags: - point-in-time - pit - ziplime - backtesting - alternative-data - finance - macro task_categories: - time-series-forecasting size_categories: - n<1K configs: - config_name: default data_files: - split: train path: data/data_bundle/**/*.parquet --- # ๐Ÿ“Š Macro Indicators โ€” Vintage / PIT (FRED-style) Macroeconomic time series with release vintages preserved โ€” every revision is a point-in-time row, so backtests see the number that was actually published, not the latest revision. Part of the **ziplime Point-in-Time (PIT) data layer** โ€” append-only datasets with an explicit split between when a fact *happened* (`event_date`) and when it became *known* (`knowledge_date`). A simulation at time **T** can only ever observe rows with `knowledge_date <= T`, so restatements, publication lag and hindsight can't leak into a backtest. The identical code path runs live with **T = now**. - **Data class:** Alternative data โ€” macro series - **Entity domain:** `macro` โ€” A macro series code (e.g. `GDPC1`, `UNRATE`) โ€” not an issuer. - **Origin:** FRED / ALFRED vintages and national statistical agencies - **License:** FRED terms โ€” mixed upstream sources - **Update cadence:** daily, ingesting new releases and revision vintages (`0 7 * * *`) - **Format:** ziplime Delta Lake bundle (`data_type: PIT_DATA`) ## Why point-in-time? Backtests on non-price data are systematically optimistic when the data layer has no notion of *when a fact became known*. Three failure modes this dataset is built to avoid: 1. **Restatements** โ€” a value reported one quarter and revised the next. Storing only the final value lets a backtest "know" the revision months early. 2. **Publication lag** โ€” fundamentals keyed by fiscal-period-end, joined to prices at period end rather than the (weeks-later) filing date. 3. **Hindsight in derived signals** โ€” a recent model scoring old text has already seen how the story ended. All three are the same bug, and it is fixed in the data layer, not in strategy code. ## Schema ### System columns (every PIT dataset) | Column | Type | Semantics | |---|---|---| | `entity_id` | Utf8 | Stable entity identifier (resolved via the `entity_map` PIT dataset) | | `event_date` | Timestamp(UTC, ยตs) | The moment the fact refers to | | `knowledge_date` | Timestamp(UTC, ยตs) | The moment it became publicly known โ€” **the only column the as-of filter uses** | | `knowledge_estimated` | Boolean | `true` if `knowledge_date` was reconstructed by a lag model rather than taken from the source | | `ingested_at` | Timestamp(UTC, ยตs) | When our pipeline wrote the row (audit only; never used in as-of) | ### Value columns (this dataset) | Column | Type | Description | |---|---|---| | `series_value` | Float64 | Value for the period, as published in this vintage | | `unit` | Utf8 | Unit of measure | | `native_frequency` | Utf8 | `D` / `W` / `M` / `Q` | | `release_kind` | Utf8 | `initial` or `revision` | The logical key of a fact is `(entity_id, event_date)`. A **revision** is a new row with the same key and a later `knowledge_date`. Written rows are immutable; history is never rewritten. ## As-of access Inside a ziplime strategy there is **no `T` parameter** โ€” the knowledge moment always equals the simulation clock (live: wall clock): ```python async def initialize(context): context.ds = await context.pit("macro-indicators") async def handle_data(context, data): # only rows with knowledge_date <= current simulation time are visible latest = await context.ds.latest( assets=[context.asset], fields=['series_value', 'unit'] ) history = await context.ds.as_of( assets=[context.asset], fields=['series_value'], event_range=("2022-01-01", None), ) ``` ### Reading it outside ziplime (plain Polars + delta-rs) ```python import polars as pl T = "2025-06-01T00:00:00Z" # "what was known at T" lf = pl.scan_delta("hf://datasets/ZipLime/macro-indicators/data/data_bundle/yahoo_finance_daily_data/1784755946/data.delta") as_of = ( lf.filter(pl.col("knowledge_date") <= T) .sort("knowledge_date") .group_by(["entity_id", "event_date"], maintain_order=True) .last() ) print(as_of.collect()) ``` Delta time-travel (`AS OF `) pins the table for reproducibility; the `knowledge_date <= T` filter is what enforces point-in-time. They compose: a backtest records `(dataset, delta_version)` and replays read the table at that version *and* apply the filter. ## Updates `recipe.py` implements the collection contract `fetch(since: datetime) -> pl.DataFrame` in the PIT schema above; `ingest.py` dedups and **appends** to the Delta bundle (never rewrites). The scheduled job in `.github/workflows/update.yml` runs it daily, ingesting new releases and revision vintages. ```python # recipe.py (contract) async def fetch(since: datetime) -> "pl.DataFrame": ... ``` ## Knowledge-date convention `knowledge_date` = the release timestamp of that vintage. Macro data is the textbook revision case: an initial GDP print and its later revisions share `(entity_id, event_date)` but differ in `knowledge_date`. `as_of(T)` returns the vintage that was actually on the wire at T โ€” the number a strategy could have traded on โ€” not the revised figure that only exists today. ## What's in this repo ``` README.md # this card manifest.json # PIT dataset manifest (schema, source, schedule) recipe.py # fetch(since) -> PIT rows ingest.py # dedup + append-only Delta writer .github/workflows/update.yml # scheduled ingestion data/ # ziplime Delta bundle + registry manifest bundle_registry/yahoo_finance_daily_data_1784755946.json data_bundle/yahoo_finance_daily_data/1784755946/data.delta/ ``` The `data/` bundle is a ready-to-load ziplime Delta Lake market-data bundle (five US equity tickers, daily bars) that seeds the pipeline and lets you exercise the loader end-to-end today. Point `pl.scan_delta` (above) at it, or register it with ziplime's `FileSystemBundleRegistry`. --- Generated for the ziplime PIT data-layer prototype. Manifest and schema follow the ziplime PIT spec; `source.*` fields declare origin and license per the dataset manifest.