mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-26 01:24:59 +02:00
feat(stocks): add dividend growth analysis to stock analysis panel (#2927)
* feat(stocks): add dividend growth analysis to stock analysis panel Shows yield, 5Y CAGR, frequency (quarterly/monthly/annual), payout ratio, and ex-dividend date. Hidden for non-dividend stocks. Data from Yahoo Finance dividend history. * fix(stocks): bump cache key + fix partial-year CAGR + remove misleading avg yield * fix(stocks): hydrate payout ratio, drop dead five-year yield, currency-aware dividend rate - Add fetchPayoutRatio helper that calls Yahoo quoteSummary's summaryDetail module in parallel with the dividend chart fetch and returns the raw 0-1 payout ratio (or undefined when missing/non-positive). The chart endpoint alone never returns payoutRatio, which is why it was hardcoded to 0. - Make payout_ratio optional in proto and DividendProfile so a missing value is undefined instead of 0; remove five_year_avg_dividend_yield entirely (proto reserved 51) since it was always returned as 0 and never wired up. - StockAnalysisPanel.renderDividendProfile now omits the Payout Ratio cell unless the value is present and > 0, formats it as (raw * 100).toFixed(1)%, and renders the dividend rate via Intl.NumberFormat with item.currency so EUR/GBP/JPY tickers no longer get a hardcoded "$" prefix. - Bump live cache key v2 -> v3 so any cached snapshots persisted with the old shape are refetched once. - Tests cover: payoutRatio populated from summaryDetail, payoutRatio undefined when summaryDetail returns 500 or raw=0, dividend response shape no longer contains fiveYearAvgDividendYield. * fix(stocks): bump persisted history store to v3 to rotate pre-PR snapshots Live analyze-stock cache was already bumped to v3, but the persisted history store (premium-stock-store.ts) still used v2 keys for index/item lookups. Pre-PR snapshots without the new dividend fields could pass the age-only freshness check and suppress a live refetch, leaving the new dividend section missing for up to 15 minutes. Bumping the persisted store keys to v3 makes old snapshots invisible. The data loader sees an empty history, triggers a live refetch, and repopulates under the new v3 keys. Old v2 keys expire via TTL. * fix(stocks): compute dividend CAGR correctly for quarterly/semiannual/annual payers Previously computeDividendCagr() required at least 10 distinct dividend months for a year to count as "full", which excluded every non-monthly dividend payer (quarterly = 4 months, semiannual = 2, annual = 1). CAGR therefore collapsed to 0/N/A for most ordinary dividend stocks. The new check uses calendar position: any year strictly earlier than the current calendar year is treated as complete, and the current in-progress year is excluded to avoid penalizing stocks whose next payment has not yet landed. * test(stocks): pass analystData to buildAnalysisResponse after rebase onto #2926
This commit is contained in:
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user