Files
worldmonitor/server/_shared
Elie Habib d1cb0e3c10 feat(sectors): add P/E valuation benchmarking to sector heatmap (#2929)
* feat(sectors): add P/E valuation benchmarking to sector heatmap

Trailing/forward P/E, beta, and returns for 12 sector ETFs from Yahoo
Finance. Horizontal bar chart color-coded by valuation level plus
sortable table. Extends existing sector data pipeline.

* fix(sectors): clear stale valuations on empty refresh + document cache behavior

* fix(sectors): force valuation rollout for cached + breaker-persisted bootstraps

- Bumped market:sectors bootstrap key v1 -> v2 so stale 24h slow-tier
  payloads without the new valuations field are invisible to returning
  users on next page load
- Versioned the fetchSectors circuit-breaker (name -> "Sector Summary v2")
  so old localStorage/IndexedDB entries predating this PR cannot be
  returned as stale via the SWR path
- shouldCache now requires the valuations field to be present on the
  cached response, not just a non-empty sectors array
- loadMarkets no longer clears the valuations tab when a hydrated or
  fresh payload lacks the field; prior render is left intact, matching
  the finding's requirement
- Defensive check: hydrated payloads without valuations fall through to
  a live fetch instead of rendering an empty valuations tab

* fix(stocks): correct beta3Year source and null YTD color in sector P/E view

- scripts/ais-relay.cjs: beta3Year lives on defaultKeyStatistics (ks),
  not summaryDetail (sd); the previous fallback was a silent no-op.
- src/components/MarketPanel.ts: null ytdReturn now renders with
  var(--text-dim) instead of var(--red); the '--' placeholder no
  longer looks like a loss.

Addresses greptile review on PR #2929.
2026-04-11 16:51:35 +04:00
..