yahooquery
yahooquery copied to clipboard
error with news
Describe the bug when print, recieved this: ['error'] (the script ends with no error)
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior First time I use this ... but supposed to recieve data
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS] win11
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
Do you have an example of the code you ran and the error you saw?
from yahooquery import Ticker
import yahooquery as yh
def news(symbols):
aapl = Ticker(symbols)
newss=aapl.news(5, start= "2023-1-1")
print("noticias noticiosas de yahooquerys",newss)
symbols= "GOOG"
news(symbols)
noticias noticiosas de yahooquerys ['error']
also (I can't asq a q, but I will ask here: is it possible to get the marketcap, sectors, industries and name with yahooqueries? with what? (I cant find indsutries)
@jsgaston Read the documentation https://yahooquery.dpguthrie.com/guide/
I'm getting this issue too with the following code:
class YahooFinance:
"""
A class for accessing financial data using YahooQuery.
Attributes:
symbol (str): The ticker symbol for the company (default: 'MSFT').
ticker (Ticker): The ticker object for the company (default: 'MSFT').
Methods:
get_security_type: Retrieves the security type.
get_historical_data: Retrieves the company's historical stock price data for the specified period.
get_balance_sheet: Retrieves the company's balance sheet data for the specified period.
"""
def __init__(self, symbol: str = 'MSFT') -> None:
"""
Initializes a new instance of the YahooFinance class.
Args:
symbol (str): The ticker symbol for the company (default: 'MSFT').
"""
self.symbol = symbol
self.ticker = Ticker(self.symbol)
def get_news(self, count: int = 25, start_date: str = '2023-01-01') -> List[Dict]:
"""
Retrieves the latest news articles related to the company.
Args:
count (int): The number of news articles to retrieve (default: 10).
Returns:
A list of dictionaries containing the news article information.
"""
news_data = self.ticker.news(count=count, start=start_date)
for article in news_data:
print(article)
article['provider_publish_time'] = datetime.fromtimestamp(article['provider_publish_time']).strftime('%Y-%m-%d')
return news_data
if __name__ == '__main__':
msft = YahooFinance(symbol='MSFT')
financial_news = msft.get_news(count=5, start_date='2023-01-01')
print(financial_news)
Just prints ['error'] to the terminal. Any ideas?
This was raised a few months ago in #44 also. I’m pretty certain that YF has deprecated this API and I’ll plan on removing this method in a later version. I’ll keep this issue open for anyone else that runs into this and it will close it out once the method is removed.
Any suggestions for alternative news source APIs?
@noobmldude @jsgaston @dpguthrie Wondering if it would be worth it to just use their RSS feed, it seems decent: https://feeds.finance.yahoo.com/rss/2.0/headline?s=AAPL®ion=US&lang=en-US