--- license: cc0-1.0 language: - en pretty_name: US Congress Trading Disclosures (PIT) tags: - point-in-time - pit - ziplime - backtesting - alternative-data - finance - us_equities task_categories: - time-series-forecasting size_categories: - n<1K configs: - config_name: default data_files: - split: train path: data/data_bundle/**/*.parquet --- # ๐Ÿ›๏ธ US Congress Trading Disclosures (PIT) Securities transactions disclosed by members of the US Congress under the STOCK Act, point-in-time by disclosure date. 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 โ€” political trading disclosures - **Entity domain:** `us_equities` โ€” The traded US-listed security (ticker); the filer is carried as a value column. - **Origin:** US House Clerk & Senate eFD periodic transaction reports (STOCK Act) - **License:** US Government work โ€” public domain - **Update cadence:** daily, sweeping newly published periodic transaction reports (`0 6 * * *`) - **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. > **Estimated knowledge dates:** rows where the source gives no publication time are modelled with the `stock_act_statutory_45d` lag and marked `knowledge_estimated = true`. Filter or discount them for a stricter run. ## 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 | |---|---|---| | `representative` | Utf8 | Name of the filing member of Congress | | `chamber` | Utf8 | `house` or `senate` | | `transaction_type` | Utf8 | `purchase` / `sale` / `exchange` | | `asset_ticker` | Utf8 | Traded ticker (mirrors `entity_id`) | | `amount_low` | Float64 | Disclosed USD range, lower bound | | `amount_high` | Float64 | Disclosed USD range, upper bound | | `disclosure_lag_days` | Int64 | Days between trade and public disclosure | 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("congress-trading") 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=['representative', 'chamber'] ) history = await context.ds.as_of( assets=[context.asset], fields=['representative'], 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/congress-trading/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, sweeping newly published periodic transaction reports. ```python # recipe.py (contract) async def fetch(since: datetime) -> "pl.DataFrame": ... ``` ## Knowledge-date convention `knowledge_date` = the disclosure filing timestamp. The STOCK Act allows members to disclose up to 45 days after a trade, so `event_date` (trade date) can lead `knowledge_date` by weeks โ€” exactly the publication-lag trap PIT exists to close. Filings that carry only a date (no time) are rounded up to end-of-day ET; filings with no timestamp at all fall back to `event_date + 45d` and are flagged `knowledge_estimated = true`. ## 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.