mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-05-01 14:33:10 +03:00
fix: add yf_retry to yfinance news fetchers (#445)
This commit is contained in:
@@ -4,6 +4,8 @@ import yfinance as yf
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
|
from .stockstats_utils import yf_retry
|
||||||
|
|
||||||
|
|
||||||
def _extract_article_data(article: dict) -> dict:
|
def _extract_article_data(article: dict) -> dict:
|
||||||
"""Extract article data from yfinance news format (handles nested 'content' structure)."""
|
"""Extract article data from yfinance news format (handles nested 'content' structure)."""
|
||||||
@@ -64,7 +66,7 @@ def get_news_yfinance(
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
stock = yf.Ticker(ticker)
|
stock = yf.Ticker(ticker)
|
||||||
news = stock.get_news(count=20)
|
news = yf_retry(lambda: stock.get_news(count=20))
|
||||||
|
|
||||||
if not news:
|
if not news:
|
||||||
return f"No news found for {ticker}"
|
return f"No news found for {ticker}"
|
||||||
@@ -131,11 +133,11 @@ def get_global_news_yfinance(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for query in search_queries:
|
for query in search_queries:
|
||||||
search = yf.Search(
|
search = yf_retry(lambda q=query: yf.Search(
|
||||||
query=query,
|
query=q,
|
||||||
news_count=limit,
|
news_count=limit,
|
||||||
enable_fuzzy_query=True,
|
enable_fuzzy_query=True,
|
||||||
)
|
))
|
||||||
|
|
||||||
if search.news:
|
if search.news:
|
||||||
for article in search.news:
|
for article in search.news:
|
||||||
|
|||||||
Reference in New Issue
Block a user