diff options
| author | Tyler <tyler@tylerhoang.xyz> | 2026-03-29 17:53:09 -0700 |
|---|---|---|
| committer | Tyler <tyler@tylerhoang.xyz> | 2026-03-29 17:53:09 -0700 |
| commit | 678d3290e87a2043b4cb338df6cb93307e91ffc1 (patch) | |
| tree | 59d368cb27752dc286197b2b0f82c5a91c24dcbb | |
| parent | 3e1324eff69e4b121f85223758b872c7fb5dc027 (diff) | |
Migrate FMP ratios and improve comps fallbacks
Switch historical ratios, key metrics, and analyst estimates from
deprecated v3 legacy endpoints to stable API equivalents.
Quarterly analyst estimates dropped (premium-only on stable API).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | services/fmp_service.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/services/fmp_service.py b/services/fmp_service.py index 0a3419d..bba6c85 100644 --- a/services/fmp_service.py +++ b/services/fmp_service.py @@ -122,29 +122,24 @@ def get_company_news(ticker: str, limit: int = 20) -> list[dict]: @st.cache_data(ttl=86400) def get_historical_ratios(ticker: str, limit: int = 10) -> list[dict]: """Annual historical valuation ratios (P/E, P/B, P/S, EV/EBITDA, etc.).""" - data = _get(LEGACY_BASE, f"/ratios/{ticker.upper()}", params={"limit": limit}) + data = _get(STABLE_BASE, "/ratios", params={"symbol": ticker.upper(), "limit": limit}) return data if isinstance(data, list) else [] @st.cache_data(ttl=86400) def get_historical_key_metrics(ticker: str, limit: int = 10) -> list[dict]: """Annual historical key metrics (ROE, ROA, margins, debt/equity, etc.).""" - data = _get(LEGACY_BASE, f"/key-metrics/{ticker.upper()}", params={"limit": limit}) + data = _get(STABLE_BASE, "/key-metrics", params={"symbol": ticker.upper(), "limit": limit}) return data if isinstance(data, list) else [] @st.cache_data(ttl=3600) def get_analyst_estimates(ticker: str) -> dict: - """Return annual and quarterly forward analyst estimates.""" - annual = _get(LEGACY_BASE, f"/analyst-estimates/{ticker.upper()}", params={"limit": 5}) - quarterly = _get( - LEGACY_BASE, - f"/analyst-estimates/{ticker.upper()}", - params={"limit": 10, "period": "quarter"}, - ) + """Return forward analyst estimates (annual only — quarterly requires premium).""" + annual = _get(STABLE_BASE, "/analyst-estimates", params={"symbol": ticker.upper(), "limit": 5, "period": "annual"}) return { "annual": annual if isinstance(annual, list) else [], - "quarterly": quarterly if isinstance(quarterly, list) else [], + "quarterly": [], } |
