From 2de6ae37b902e3632ea62b904164552538501ec3 Mon Sep 17 00:00:00 2001 From: Openclaw Date: Mon, 30 Mar 2026 19:36:42 -0700 Subject: Unify valuation calculations across Prism - compute EV consistently as market cap + debt - cash - derive DCF/EV bridge inputs from balance-sheet rows - centralize latest price, shares outstanding, and computed market cap helpers - relabel negative net debt as net cash in valuation UI - self-compute historical ratios/key metrics instead of relying on vendor ratios - guard against nonsensical historical EV/EBITDA values - add methodology/source notes in DCF tab --- services/fmp_service.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'services/fmp_service.py') 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) -- cgit v1.3-2-g0d8e