Stale XBRL tags: take every metric from the latest 10-K (#1) #41
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
epic:E1-foundation
epic:E2-correct-metrics
epic:E3-fast-jobs
epic:E4-cli
epic:E5-web-ui
epic:E6-history
good first issue
help wanted
invalid
question
sprint-tracking
story
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/screener!41
Loading…
Reference in a new issue
No description provided.
Delete branch "1-stale-xbrl-tags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
🤖 Claude: Closes #1
analyze.tspicked, for each metric, the first XBRL tag with any 10-K value, however old. The fix (latest fiscal-year extraction) already existed insrc/extract.tsfrom #8, but the legacy script didn't use it. It now does:src/analyze.ts(analyzeCompany): new. Builds onecompany_analysisrow fromextractFiscalYearFacts+computeMetrics.analyze.tskeeps only the file loop and the DB upsert, and the old extraction code (~250 lines) is deleted.src/extract.ts: also reads the 10-K's filing date, stockholders' equity (at the fiscal year-end), and the cover-page shares outstanding and public float. The cover-page values are matched by the 10-K's accession number, because they're dated at the cover or the prior Q2, not the fiscal year-end. A missing value is null. The old script fell back to other share tags and older filings.src/metrics.ts: exposescashAndInvestments, so the row'scashis what EV subtracts.Column meanings that changed (they now follow the Greenblatt definitions from #9):
cash= cash + short-term investments,totalDebtincludes finance leases,netWorkingCapitalis floored at 0,netFixedAssetsincludes finance-lease ROU assets. ROTC and EY are null when tangible capital or EV is ≤ 0. The SQL EY recalculation inexport-ranking.ts(ebit / (mcap + totalDebt − cash)) still matchescomputeMetrics.Definition of Done
Acceptance criteria met and demonstrated. The issue's table, from a real-data run of
analyze.ts:Every row field now comes from the one fiscal year that
extractFiscalYearFactsselects, so no input can be older than the latest 10-K.bun testpasses; new logic has tests: 151 pass, 0 fail. New tests aretest/analyze.test.ts(the four cases above plus row semantics) and the cover-page/equity tests intest/extract.test.ts.bun checkis clean (17 files) andbun fmt --checkpasses on the changed files.Runs end to end on real data (partly).
analyze.ts→export-ranking.tsran on a copy of the local DB with all 20,547 SEC files: 5,457 fresh companies, 0 errors, 1,449 ranked.enrich-prices.tswas not re-run (about an hour at 1 request/s), so prices are from the earlier run. On that same DB,mainalso ranks about 1,420, so the jump from the 288 in the Nov 5 CSV isn't from this change. It comes from the earlier eligibility rework, which stopped excluding companies that should have been ranked; the DB hasn't been repriced since. A fullbun run pipelineis still needed.Not in scope, seen while verifying: near-zero tangible capital still gives extreme ROTC (ATRA 49,126%). That's #34, handled by #36's bounds.
🤖 Generated with Claude Code
Code review
No issues found. Checked for bugs and CLAUDE.md compliance.
in the interest of keeping things moving, i'm not going to run the full pipeline. a subset of the full data was used successfully, i believe it's unlikely we'll run into any issues once the full dataset is in play.