yahooquery icon indicating copy to clipboard operation
yahooquery copied to clipboard

error with news

Open jsgaston opened this issue 2 years ago • 9 comments

Describe the bug when print, recieved this: ['error'] (the script ends with no error)

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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.

jsgaston avatar Feb 18 '23 20:02 jsgaston

Do you have an example of the code you ran and the error you saw?

dpguthrie avatar Feb 19 '23 00:02 dpguthrie

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)

jsgaston avatar Feb 19 '23 01:02 jsgaston

noticias noticiosas de yahooquerys ['error']

jsgaston avatar Feb 19 '23 21:02 jsgaston

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 avatar Feb 19 '23 21:02 jsgaston

@jsgaston Read the documentation https://yahooquery.dpguthrie.com/guide/

ValueRaider avatar Feb 20 '23 12:02 ValueRaider

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?

killianmcshane avatar Feb 20 '23 14:02 killianmcshane

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.

dpguthrie avatar Feb 20 '23 15:02 dpguthrie

Any suggestions for alternative news source APIs?

noobmldude avatar May 28 '23 09:05 noobmldude

@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&region=US&lang=en-US

helphp avatar May 11 '24 14:05 helphp