diff options
| author | Openclaw <openclaw@mail.tylerhoang.xyz> | 2026-03-30 19:36:42 -0700 |
|---|---|---|
| committer | Openclaw <openclaw@mail.tylerhoang.xyz> | 2026-03-30 19:36:42 -0700 |
| commit | 2de6ae37b902e3632ea62b904164552538501ec3 (patch) | |
| tree | 1fef3aa3df32dc27278e2be7d5b8fd88cb9bae06 /services/fmp_service.py | |
| parent | 7a169d4f2bfeb79735823c1eb39f9162329b240e (diff) | |
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
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) |
