ZipLime's picture
Docs: use snapshot_download + scan_delta for the runnable as-of example
4fc44fb verified
|
Raw
History Blame Contribute Delete
6.26 kB
metadata
license: cc0-1.0
language:
  - en
pretty_name: SEC EDGAR Fundamentals (PIT)
tags:
  - point-in-time
  - pit
  - ziplime
  - backtesting
  - fundamentals
  - sec-edgar
  - us_equities
task_categories:
  - time-series-forecasting
size_categories:
  - 10K<n<100K
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/data_bundle/**/*.parquet

🧾 SEC EDGAR Fundamentals (PIT)

Point-in-time company fundamentals from SEC filings — revenue, diluted EPS, net income and total assets, keyed by filing time, not fiscal period. Every figure is stored as it was reported, so restatements and publication lag can't leak into a backtest.

Part of the ziplime Point-in-Time (PIT) data layer: a simulation at time T only ever observes rows with knowledge_date <= T. The identical code path runs live with T = now.

  • Data class: Fundamentals — SEC filings (XBRL company facts)
  • Entity domain: us_equities — US-listed issuer, keyed by ticker
  • Coverage: 93 issuers, 23,580 as-reported facts (including restatement history)
  • event_date range: 2006-12-31 → 2026-06-13
  • knowledge_date range: 2009-05-07 → 2026-07-09
  • Origin: SEC EDGAR company facts (XBRL) · US-Government public domain
  • Update cadence: daily, following the EDGAR filing index (0 5 * * *)
  • Format: ziplime Delta Lake bundle (data_type: PIT_DATA), partitioned by knowledge_year

Why point-in-time?

A conventional fundamentals table stores one value per fact — the final one. A backtest then trades in August on a number that was only restated in October. This dataset keeps the split:

Column Type Semantics
entity_id Utf8 Ticker of the issuer
event_date Timestamp(UTC, µs) Period end the figure refers to
knowledge_date Timestamp(UTC, µs) Filing date it became public — the only column the as-of filter uses
knowledge_estimated Boolean true if the filing date was modelled rather than sourced (here: always false)
ingested_at Timestamp(UTC, µs) Pipeline write time (audit only)

Value columns

Column Type Description
revenue Float64 Total revenue for the period
eps_diluted Float64 Diluted earnings per share
net_income Float64 Net income
total_assets Float64 Total assets (balance-sheet date)
fiscal_period Utf8 e.g. FY2024, 2024Q3
form Utf8 Filing form: 10-K, 10-Q, 10-K/A, …
accession_no Utf8 SEC accession number (provenance)

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 — a restatement, or the same period re-reported as a comparative in a later filing.

Restatement in the data — a worked example

Apple's FY2008 (event_date = 2008-09-27) as it actually became known:

knowledge_date form revenue eps_diluted
2009-10-27 10-K 32.48 B 5.36
2010-01-25 10-K/A 37.49 B 6.78

The 10-K/A is Apple's retrospective adoption of new revenue-recognition rules. as_of("2009-11-01") returns 32.48 B — the only figure a strategy could have traded on that day. as_of("2010-02-01") returns 37.49 B. The restated number never leaks backwards.

As-of access

Inside a ziplime strategy there is no T parameter — the knowledge moment equals the simulation clock:

async def initialize(context):
    context.fundamentals = await context.pit("sec-fundamentals-pit")

async def handle_data(context, data):
    latest = await context.fundamentals.latest(
        assets=[context.asset], fields=["revenue", "eps_diluted"]
    )
    history = await context.fundamentals.as_of(
        assets=[context.asset], fields=["revenue"], event_range=("2018-01-01", None)
    )

Reading it outside ziplime (plain Polars + delta-rs)

import polars as pl
from datetime import datetime, timezone
from huggingface_hub import snapshot_download

path = snapshot_download(
    "ZipLime/sec-fundamentals-pit", repo_type="dataset",
    allow_patterns=["data/data_bundle/**"],
)
delta = f"{path}/data/data_bundle/sec_fundamentals_pit/1784818614/data.delta"

T = datetime(2009, 11, 1, tzinfo=timezone.utc)   # "what was known at T"
as_of = (
    pl.scan_delta(delta)
      .filter(pl.col("knowledge_date") <= T)     # point-in-time filter
      .sort("knowledge_date")
      .group_by(["entity_id", "event_date"], maintain_order=True)
      .last()
)
print(as_of.filter(pl.col("entity_id") == "AAPL").collect())

The table is partitioned by knowledge_year, so the knowledge_date <= T filter prunes at the partition level. Delta time-travel (AS OF <version>) pins the table for reproducibility; it composes with the knowledge filter rather than replacing it.

Updates

recipe.py implements fetch(since) -> pl.DataFrame against SEC company facts; ingest.py dedups and appends to the Delta bundle (never rewrites). The scheduled job in .github/workflows/update.yml runs it daily.

What's in this repo

README.md                     # this card
manifest.json                 # PIT manifest (schema, source, coverage)
recipe.py                     # fetch(since) -> PIT rows from SEC company facts
ingest.py                     # dedup + append-only Delta writer
.github/workflows/update.yml  # scheduled ingestion
data/                         # ziplime Delta bundle + registry manifest
  bundle_registry/sec_fundamentals_pit_1784818614.json
  data_bundle/sec_fundamentals_pit/1784818614/data.delta/   (partitioned by knowledge_year)

To load with ziplime, drop data/bundle_registry/* and data/data_bundle/* into your ~/.ziplime/data/ and read via context.pit("sec-fundamentals-pit"); or point pl.scan_delta straight at the Delta table as shown above.

Provenance & license

Built from SEC EDGAR XBRL company facts (public domain, US Government work) via the dartlab-data mirror, repackaged into the ziplime PIT schema. Filing dates (filed) are used verbatim as knowledge_date; fact periods are classified from each fact's own reporting window. No values are imputed.