refactor: add limit parameter to get_news_yfinance for consistency
Address review feedback: make hardcoded count=20 a configurable limit parameter, consistent with get_global_news_yfinance.
This commit is contained in:
parent
1a8ec533c0
commit
5b5a9b9aee
|
|
@ -52,6 +52,7 @@ def get_news_yfinance(
|
||||||
ticker: str,
|
ticker: str,
|
||||||
start_date: str,
|
start_date: str,
|
||||||
end_date: str,
|
end_date: str,
|
||||||
|
limit: int = 20,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Retrieve news for a specific stock ticker using yfinance.
|
Retrieve news for a specific stock ticker using yfinance.
|
||||||
|
|
@ -60,13 +61,14 @@ def get_news_yfinance(
|
||||||
ticker: Stock ticker symbol (e.g., "AAPL")
|
ticker: Stock ticker symbol (e.g., "AAPL")
|
||||||
start_date: Start date in yyyy-mm-dd format
|
start_date: Start date in yyyy-mm-dd format
|
||||||
end_date: End date in yyyy-mm-dd format
|
end_date: End date in yyyy-mm-dd format
|
||||||
|
limit: Maximum number of news articles to fetch (default: 20)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Formatted string containing news articles
|
Formatted string containing news articles
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
stock = yf.Ticker(ticker)
|
stock = yf.Ticker(ticker)
|
||||||
news = yf_retry(lambda: stock.get_news(count=20))
|
news = yf_retry(lambda: stock.get_news(count=limit))
|
||||||
|
|
||||||
if not news:
|
if not news:
|
||||||
return f"No news found for {ticker}"
|
return f"No news found for {ticker}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue