From a4e33d7a390c3ac5a4b8b141d78e728c2e7ab5d1 Mon Sep 17 00:00:00 2001 From: Dennis Thiessen Date: Wed, 22 Jul 2026 11:50:38 +0200 Subject: [PATCH] feat(dolt): add shares_outstanding_date to fundamental_snapshots (026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A1 carry-forward. The SEC cover-page share count (dei:EntityCommonStockSharesOutstanding) is reported "as of" its own date, which can differ from the fiscal period_end — store that date so market cap uses the right point-in-time count. Migration 026 edited in place (never run with data). Co-Authored-By: Claude Opus 4.8 --- alembic/versions/026_dolt_fundamentals_schema.py | 1 + app/models/fundamental_snapshot.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/alembic/versions/026_dolt_fundamentals_schema.py b/alembic/versions/026_dolt_fundamentals_schema.py index 3e2dd8c..e884578 100644 --- a/alembic/versions/026_dolt_fundamentals_schema.py +++ b/alembic/versions/026_dolt_fundamentals_schema.py @@ -66,6 +66,7 @@ def upgrade() -> None: sa.Column("cash_and_st_investments", sa.Float(), nullable=True), sa.Column("total_debt", sa.Float(), nullable=True), sa.Column("shares_outstanding", sa.Float(), nullable=True), + sa.Column("shares_outstanding_date", sa.Date(), nullable=True), sa.Column( "import_run_id", sa.Integer(), diff --git a/app/models/fundamental_snapshot.py b/app/models/fundamental_snapshot.py index 4e85885..addfee4 100644 --- a/app/models/fundamental_snapshot.py +++ b/app/models/fundamental_snapshot.py @@ -64,6 +64,10 @@ class FundamentalSnapshot(Base): cash_and_st_investments: Mapped[float | None] = mapped_column(Float, nullable=True) total_debt: Mapped[float | None] = mapped_column(Float, nullable=True) shares_outstanding: Mapped[float | None] = mapped_column(Float, nullable=True) + # The cover-page share count (dei:EntityCommonStockSharesOutstanding) is + # reported "as of" its own date, which can differ from period_end — store it + # so market cap uses the right point-in-time count. + shares_outstanding_date: Mapped[date | None] = mapped_column(Date, nullable=True) import_run_id: Mapped[int | None] = mapped_column( ForeignKey("data_import_runs.id", ondelete="SET NULL"), nullable=True