Batched Yahoo quotes #13

Closed
opened 2026-11-06 01:19:16 +00:00 by chris-kreidl · 2 comments
chris-kreidl commented 2026-11-06 01:19:16 +00:00 (Migrated from github.com)

Fetch ~100 symbols per request instead of 1 request/second for each company.

Acceptance criteria

  • Prices and market caps are fetched in batches of up to 100 symbols.
  • Sector and industry are fetched only when missing.
  • A full re-price of an already-enriched DB takes under 5 minutes.
  • Companies with no quote still get their old price cleared.

Definition of Done

  • Acceptance criteria met and demonstrated
  • bun test passes; new logic has tests
  • bun check is clean and bun fmt --check passes
  • Runs end to end on real data (not just fixtures)
  • Committed with Closes #<this issue>

Considerations

enrich-prices.ts makes one quoteSummary call per company, with a 1-second sleep between calls. For about 4,900 companies that's roughly 80 minutes. yahoo-finance2's quote([...symbols]) accepts many symbols per request, so prices for everyone would take about 50 requests and well under a minute.

The catch: batched quote() returns regularMarketPrice and marketCap but not sector or industry. Those only come from quoteSummary's summaryProfile, one symbol at a time. And sector isn't cosmetic: src/eligibility.ts:51 uses it to exclude financials and utilities.

Fetch ~100 symbols per request instead of 1 request/second for each company. ### Acceptance criteria - [ ] Prices and market caps are fetched in batches of up to 100 symbols. - [ ] Sector and industry are fetched only when missing. - [ ] A full re-price of an already-enriched DB takes under 5 minutes. - [ ] Companies with no quote still get their old price cleared. ### Definition of Done - [ ] Acceptance criteria met and demonstrated - [ ] `bun test` passes; new logic has tests - [ ] `bun check` is clean and `bun fmt --check` passes - [ ] Runs end to end on real data (not just fixtures) - [ ] Committed with `Closes #<this issue>` ### Considerations `enrich-prices.ts` makes one `quoteSummary` call per company, with a 1-second sleep between calls. For about 4,900 companies that's roughly 80 minutes. `yahoo-finance2`'s `quote([...symbols])` accepts many symbols per request, so prices for everyone would take about 50 requests and well under a minute. The catch: batched `quote()` returns `regularMarketPrice` and `marketCap` but not sector or industry. Those only come from `quoteSummary`'s `summaryProfile`, one symbol at a time. And sector isn't cosmetic: src/eligibility.ts:51 uses it to exclude financials and utilities.
chris-kreidl commented 2026-11-11 20:24:48 +00:00 (Migrated from github.com)

🤖 Claude: Proposed changes to the acceptance criteria (backlog refinement)

Two things have changed since this was written:

  • Enrich now prices ~1,680 companies (the eligible ones), not ~4,900, so a run takes ~28 min, not ~80.
  • Since #45, an unknown sector excludes a company. Batched quote() has no sector, so this story can't ship before #14 (the sector cache) without dropping every company from the ranking. I propose moving "Sector and industry are fetched only when missing" to #14, so this story is only about prices.

Acceptance criteria (revised)

  • Prices and market caps are fetched with quote() in batches of up to 100 symbols.
  • Sector and industry come from #14's cache. This story makes no quoteSummary calls of its own.
  • Companies with no quote still get their old price cleared (#5), and those with no ticker still get it cleared too.
  • Only Yahoo's market cap is used, with no fallback (#40).
  • A full re-price of an already-enriched DB takes under 5 minutes.
  • Parity, on real data: the same companies are priced as with the per-company quoteSummary path. Any difference is listed and explained in the PR.

Questions

  1. Move the sector criterion to #14, as above?
  2. The 5-minute target was set when this was 80 minutes; with batching it should be under 1 minute. Keep 5 as a safe bound, or tighten it?

Dependencies

Needs #14 first.

🤖 **Claude:** **Proposed changes to the acceptance criteria** (backlog refinement) Two things have changed since this was written: - Enrich now prices **~1,680** companies (the eligible ones), not ~4,900, so a run takes ~28 min, not ~80. - Since #45, **an unknown sector excludes a company.** Batched `quote()` has no sector, so this story can't ship before #14 (the sector cache) without dropping every company from the ranking. I propose moving "Sector and industry are fetched only when missing" to #14, so this story is only about prices. ### Acceptance criteria (revised) - [ ] Prices and market caps are fetched with `quote()` in batches of up to 100 symbols. - [ ] Sector and industry come from #14's cache. This story makes no `quoteSummary` calls of its own. - [ ] Companies with no quote still get their old price cleared (#5), and those with no ticker still get it cleared too. - [ ] Only Yahoo's market cap is used, with no fallback (#40). - [ ] A full re-price of an already-enriched DB takes under 5 minutes. - [ ] **Parity, on real data:** the same companies are priced as with the per-company `quoteSummary` path. Any difference is listed and explained in the PR. ### Questions 1. Move the sector criterion to #14, as above? 2. The 5-minute target was set when this was 80 minutes; with batching it should be under 1 minute. Keep 5 as a safe bound, or tighten it? ### Dependencies Needs #14 first.
chris-kreidl commented 2026-11-12 13:28:25 +00:00 (Migrated from github.com)

🤖 Claude: Recording Chris's answers from the session:

  • Q1: settled when #14 shipped with the sector criterion.
  • Q2: 5 minutes is an upper bound, not a target. The real run took 17 s.
  • WAT/SUPN market-cap jumps (see #53): Chris treats them as a transient glitch in Yahoo's data at the time of the pull. No issue needed.
🤖 **Claude:** Recording Chris's answers from the session: - **Q1:** settled when #14 shipped with the sector criterion. - **Q2:** 5 minutes is an upper bound, not a target. The real run took 17 s. - **WAT/SUPN market-cap jumps** (see #53): Chris treats them as a transient glitch in Yahoo's data at the time of the pull. No issue needed.
Sign in to join this conversation.
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#13
No description provided.