Cache sector and industry by CIK (#14) #52
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!52
Loading…
Reference in a new issue
No description provided.
Delete branch "14-sector-cache"
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 #14
Enrich now caches each company's sector profile in a
sector_cachetable, keyed by CIK, and asks Yahoo for a profile only when the cache has no entry for a company or the entry is more than 90 days old.Changes
src/db.ts: adds thesector_cachetable (cik PK, ticker, sector, industry, sourceyahoo/sic, fetchedAt).src/sectors.ts(new):cachedSector(missing or >90 days → null),cacheSector,lookUpSector(Yahoo sector, else the SIC fallback from #45, else null, which is not cached and is retried next run).src/enrich.ts: checks the cache first and requests Yahoo'ssummaryProfilemodule only on a miss. Its result gainsprofileLookups, which the CLI summary shows.CLAUDE.md: structure section updated.Real-data demo (
bun cli.ts enrich rank, run twice)company_analysismatch the pre-run database for 6,020 of 6,021 companies. The exception is MGSD, which had no sector before and now getsTransportation Servicesfrom its SIC code.marketCapfor these tickers whether or not the profile module is requested, so the cache didn't cause this. It's Yahoo's data.quoteSummarycall per company. The big speedup comes with #13 (batched quotes), which builds on this PR.Definition of Done
bun testpasses (213 tests, 0 failures); new logic has tests (test/sectors.test.ts: cache key and columns, fresh/stale at 90 days, replacement, Yahoo → SIC → not cached)bun checkis clean andbun fmt --checkpasses🤖 Generated with Claude Code