diff options
Diffstat (limited to 'services/fmp_service.py')
| -rw-r--r-- | services/fmp_service.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/services/fmp_service.py b/services/fmp_service.py index 6d0ecd0..1e5ea42 100644 --- a/services/fmp_service.py +++ b/services/fmp_service.py @@ -102,23 +102,22 @@ 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.). - Falls back to yfinance-computed ratios if FMP returns empty (e.g. rate limit).""" - data = _get(STABLE_BASE, "/ratios", params={"symbol": ticker.upper(), "limit": limit}) - if isinstance(data, list) and data: - return data - return get_historical_ratios_yfinance(ticker.upper()) + + Prism computes these from raw yfinance statements + price history so the + methodology stays consistent with the rest of the app. + """ + rows = get_historical_ratios_yfinance(ticker.upper()) + return rows[:limit] if rows 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.). - Falls back to yfinance-computed metrics if FMP returns empty (e.g. rate limit).""" - data = _get(STABLE_BASE, "/key-metrics", params={"symbol": ticker.upper(), "limit": limit}) - if isinstance(data, list) and data: - return data - # yfinance fallback already covers all key metrics — return empty to avoid duplication - # (get_historical_ratios will have already provided the full merged dataset) - return [] + + Returned via the same self-computed historical dataset as get_historical_ratios(). + """ + rows = get_historical_ratios_yfinance(ticker.upper()) + return rows[:limit] if rows else [] @st.cache_data(ttl=3600) |
