Skip to content

Fix MTS fiscal-year double counting and macro data integrity - #1

Open
xcnecon wants to merge 2 commits into
mainfrom
codex/fix-data-integrity
Open

xcnecon wants to merge 2 commits into
mainfrom
codex/fix-data-integrity

Conversation

@xcnecon

@xcnecon xcnecon commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Why

A read-only audit of all 32 live data pages found several reproducible ingestion errors. Most severely, the MTS request omitted row identity, so Treasury's API aggregated current- and prior-fiscal-year months: July 2026 was stored as $723.451bn instead of $432.308bn.

Changes

  • Resolve MTS fiscal-year parents, preserve row identity, validate receipts/outlays/deficit, and upsert all available monthly history using the latest report vintage.
  • Exclude summary rows from Treasury weighted-average maturity calculations; repair existing summaries even without a new month.
  • Refresh Repo and Reverse Repo from the earlier per-type watermark, with overlap; sum completed operations and exclude repeated operation IDs.
  • Parse PBOC OMO by named columns, preserve no-operation days as zero volume and NULL rate, and revisit existing erroneous zero-rate rows.
  • Recognize NBS first-half and quarter retail release titles and backfill missing June even after July has arrived.
  • Accept FRED revisions to existing GDP, CPI and reserve observations.
  • Add 26 offline regression cases, curated official-source fixtures, and GitHub Actions CI.

Validation

  • Local: 26 tests passed using repository dependencies; Python compilation and git diff whitespace checks passed.
  • Live Treasury MTS: 137 reports / 3,090 rows reconciled into 154 monthly observations (October 2013–July 2026).
  • Actual July MSPD detail gives 5.840237 years; repeated runs in isolated SQL produce the same result.
  • Parsed six actual PBOC notices and the NBS June table (25 indicators).
  • No production MySQL access; database tests use isolated substitutes, including SQLite execution of maturity predicates.

Rollout and remaining limits

The public repository contains only ETL. Production has not been updated, and this PR is not merged. Normal targeted source updates repair the affected stored history; commands are in README.

The complete page audit records every page and the follow-up web-code findings. Official-source verification corrects the initial timing concern: private-sector NIPA net lending itself ends at 2026Q1, so the sectoral chart's Q1 endpoint is not a refresh bug. Separately stacked GDP–GDI discrepancy, duplicate STIR dates, and property monthly-value/date-filter calculations require changes in the website application. Those web changes are outside this ETL repository. The web layer must preserve missing OMO rates rather than convert NULL to zero.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T11:38:36.433516Z 691e3f9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant