Skip to main content

Point-in-time SEC EDGAR financial data pipeline

Project description

pitedgar

CI PyPI version Python versions License: MIT

Point-in-time SEC EDGAR financial data pipeline.

Downloads SEC EDGAR companyfacts.zip, parses XBRL JSON facts into a local parquet file, and exposes a query API with zero look-ahead bias — every value is stamped with the filed date (when the data was actually available to the market), not the period-end date.


Installation

pip install pitedgar
# or with Poetry
poetry install

Quick start

from pathlib import Path
from pitedgar import PitEdgarConfig, build_cik_map, download_bulk, parse_all, PitQuery

config = PitEdgarConfig(
    edgar_identity="Mario Rossi mario@example.com",  # required by SEC
    data_dir=Path("./data"),
)

# Step 1 — one-shot ticker → CIK mapping
tickers = ["AAPL", "MSFT", "JPM", "GOOGL"]
cik_map = build_cik_map(tickers, config)

# Step 2 — download ~1.5 GB bulk ZIP (do this periodically, not every run)
download_bulk(config)

# Step 3 — parse JSON → parquet (sub-minute for 500 companies)
master = parse_all(config, cik_map)

# Step 4 — query
q = PitQuery(config.data_dir / "pit_financials.parquet")

# What revenue figure was available to the market on 2022-06-30?
result = q.as_of(["AAPL", "MSFT"], "us-gaap:Revenues", "2022-06-30")

# Full history
hist = q.history("AAPL", "us-gaap:NetIncomeLoss", freq="A")

# Portfolio cross-section signal
xs = q.cross_section("us-gaap:NetIncomeLoss", "2023-12-31")

CLI

# Resolve tickers (tickers.txt has one ticker per line)
pitedgar map --tickers tickers.txt --identity "Name name@email.com"

# Download bulk ZIP
pitedgar fetch --identity "Name name@email.com"

# Parse to parquet
pitedgar build --identity "Name name@email.com"

# Query a single value
pitedgar query --ticker AAPL --concept us-gaap:Revenues --as-of 2023-06-30

Key design decisions

Decision Rationale
filed as PIT timestamp The date the filing was submitted to SEC — this is when information became public
Deduplication keeps latest filed per (concept, end) Companies sometimes refile restated figures; keep the superseding value
Raw USD values, no scale conversion SEC reports values as-filed; downstream code applies any needed normalization
Local parquet, no runtime HTTP Queries run at DataFrame speed with no network dependency

Supported XBRL concepts (defaults)

See pitedgar.config.DEFAULT_CONCEPTS for the full list, which includes revenues, net income, assets, liabilities, equity, EPS, cash, debt, operating cash flow, capex, and R&D expense.


Examples

  • examples/fcf_sp500.py — S&P 500 free cash flow benchmark: fetches constituents, builds the parquet, and queries FCF cross-sections across 20 quarters. Useful as an end-to-end performance reference.

Contributing

Contributions are welcome. See CONTRIBUTING.md for setup instructions, coding conventions, and the PR process.


License

MIT

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

pitedgar-0.2.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

pitedgar-0.2.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file pitedgar-0.2.1.tar.gz.

File metadata

  • Download URL: pitedgar-0.2.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.15 Linux/6.17.0-1008-azure

File hashes

Hashes for pitedgar-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bf58a619349d5e95e9d71d89c3a8b0a092a16531660ffdc67cc67209483a51cf
MD5 47b606e1e81ef1c6829d364ccdaa3c23
BLAKE2b-256 a2ee39bd41590652acea233b597424b9c7c62a1ade7f5e53d7d55800e26f5a99

See more details on using hashes here.

File details

Details for the file pitedgar-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pitedgar-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.15 Linux/6.17.0-1008-azure

File hashes

Hashes for pitedgar-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab6f1abd491988ebe9c8449e65790a6da088c4f85ec98c231179bb9d2976533
MD5 8dfee0c18337f452bb75eaf114afa55e
BLAKE2b-256 a3364da20d9b7df7f70bc5f574a3c4a676d2c2d6f94e12e66b7109fa8aa9fd4d

See more details on using hashes here.

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