Use the SEC SIC code when Yahoo has no sector (#45) #47

Merged
chris-kreidl merged 1 commit from 45-sic-sector-fallback into main 2026-11-11 16:31:17 +00:00
chris-kreidl commented 2026-11-11 15:54:07 +00:00 (Migrated from github.com)

🤖 Claude: Closes #45

Implements option 2 from the issue, as agreed in Chris's comment.

What changes

  • src/sic.ts (sectorFromSic): maps an SEC SIC code to a sector. Financial Services is 6000–6499 and 6700–6799. Utilities is 4900–4949 and 4960–4999. Real estate (6500–6599) and waste management (4950–4959) are not excluded. Any other code gets SEC's own description, e.g. "Services-Prepackaged Software".
  • enrich-prices.ts: when Yahoo returns a quote with no sector, it reads sic and sicDescription from data.sec.gov/submissions/CIK##########.json. That happens only for quotes with no sector, so it adds a few requests per run. The log line marks these sectors with (SIC).
  • src/eligibility.ts: a company with no sector from either source is now excluded. The issue's question 3 wasn't answered in the comment, so this uses my suggestion from the investigation. It's a one-line change if you'd rather rank them.

Expected on real data: WELPP is excluded as a utility (SIC 4911) and SWKHL as financial (SIC 6159). FISV, LION and NIQ stay ranked, with SEC's description as their sector.

Definition of Done

  • Acceptance criteria met and demonstrated: test/sic.test.ts covers WELPP's and SWKHL's codes, every range boundary, the real-estate and waste carve-outs, and missing or invalid codes. test/eligibility.test.ts now has "unknown sector is ineligible (#45)".
  • bun test passes; new logic has tests: 188 pass, 0 fail
  • bun check is clean and bun fmt --check passes: no type errors in 19 files; all changed files are formatted
  • Runs end to end on real data (not just fixtures): still needed. Run bun run enrich && bun run export, then check that WELPP and SWKHL are gone and FISV, LION and NIQ are still ranked. The SEC submissions response shape (sic as a string) wasn't live-checked from this session.

🤖 Generated with Claude Code

🤖 **Claude:** Closes #45 Implements option 2 from the issue, as agreed in Chris's comment. **What changes** - `src/sic.ts` (`sectorFromSic`): maps an SEC SIC code to a sector. Financial Services is 6000–6499 and 6700–6799. Utilities is 4900–4949 and 4960–4999. Real estate (6500–6599) and waste management (4950–4959) are not excluded. Any other code gets SEC's own description, e.g. "Services-Prepackaged Software". - `enrich-prices.ts`: when Yahoo returns a quote with no sector, it reads `sic` and `sicDescription` from `data.sec.gov/submissions/CIK##########.json`. That happens only for quotes with no sector, so it adds a few requests per run. The log line marks these sectors with `(SIC)`. - `src/eligibility.ts`: **a company with no sector from either source is now excluded.** The issue's question 3 wasn't answered in the comment, so this uses my suggestion from the investigation. It's a one-line change if you'd rather rank them. **Expected on real data:** WELPP is excluded as a utility (SIC 4911) and SWKHL as financial (SIC 6159). FISV, LION and NIQ stay ranked, with SEC's description as their sector. ### Definition of Done - [x] Acceptance criteria met and demonstrated: `test/sic.test.ts` covers WELPP's and SWKHL's codes, every range boundary, the real-estate and waste carve-outs, and missing or invalid codes. `test/eligibility.test.ts` now has "unknown sector is ineligible (#45)". - [x] `bun test` passes; new logic has tests: 188 pass, 0 fail - [x] `bun check` is clean and `bun fmt --check` passes: no type errors in 19 files; all changed files are formatted - [x] Runs end to end on real data (not just fixtures): **still needed.** Run `bun run enrich && bun run export`, then check that WELPP and SWKHL are gone and FISV, LION and NIQ are still ranked. The SEC submissions response shape (`sic` as a string) wasn't live-checked from this session. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chris-kreidl commented 2026-11-11 16:31:10 +00:00 (Migrated from github.com)

confirmed WELPP and SWKHL are gone, FISV, LION, NIQ still present.

confirmed WELPP and SWKHL are gone, FISV, LION, NIQ still present.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/screener!47
No description provided.