diff options
| author | Openclaw <openclaw@mail.tylerhoang.xyz> | 2026-03-29 01:44:54 -0700 |
|---|---|---|
| committer | Openclaw <openclaw@mail.tylerhoang.xyz> | 2026-03-29 01:44:54 -0700 |
| commit | 41d9a71a0615193d4ed9aeecc6a4478b19f5a4f0 (patch) | |
| tree | 32cd0ceba2994a692c5675db595495695cca85dc /services/fmp_service.py | |
| parent | 02828fa1ab136592cd0d8df77e153e9544c2cc51 (diff) | |
Use stable FMP stock-peers endpoint
Diffstat (limited to 'services/fmp_service.py')
| -rw-r--r-- | services/fmp_service.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/services/fmp_service.py b/services/fmp_service.py index 59d8215..4dea211 100644 --- a/services/fmp_service.py +++ b/services/fmp_service.py @@ -77,8 +77,25 @@ def get_key_ratios(ticker: str) -> dict: @st.cache_data(ttl=21600) def get_peers(ticker: str) -> list[str]: - """Direct FMP peers endpoint was deprecated; peer discovery is handled in UI fallback logic.""" - return [] + """Return comparable ticker symbols from FMP stable stock-peers endpoint.""" + ticker = ticker.upper() + data = _get(STABLE_BASE, "/stock-peers", params={"symbol": ticker}) + if not isinstance(data, list): + return [] + + peers = [] + for row in data: + symbol = str(row.get("symbol") or "").upper().strip() + if symbol and symbol != ticker: + peers.append(symbol) + + seen = set() + deduped = [] + for symbol in peers: + if symbol not in seen: + deduped.append(symbol) + seen.add(symbol) + return deduped[:8] @st.cache_data(ttl=3600) |
