fix: switch price target from FMP to yfinance
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
FMP provider requires a paid API key. yfinance provides targetMeanPrice in ticker.info for free.
This commit is contained in:
@@ -104,13 +104,15 @@ async def get_financials(symbol: str) -> dict:
|
||||
|
||||
|
||||
async def get_price_target(symbol: str) -> float | None:
|
||||
"""Get consensus analyst price target via yfinance."""
|
||||
import yfinance as yf
|
||||
|
||||
def _fetch() -> float | None:
|
||||
t = yf.Ticker(symbol)
|
||||
return t.info.get("targetMeanPrice")
|
||||
|
||||
try:
|
||||
result = await asyncio.to_thread(
|
||||
obb.equity.estimates.price_target, symbol, provider="fmp"
|
||||
)
|
||||
items = _to_dicts(result)
|
||||
if items:
|
||||
return items[0].get("adj_price_target") or items[0].get("price_target")
|
||||
return await asyncio.to_thread(_fetch)
|
||||
except Exception:
|
||||
logger.warning("Failed to get price target for %s", symbol, exc_info=True)
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user