-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_historical_price_data() error #186
Comments
I've been having the same issue with this code. I'm taking a Quantitative Analytics Course and am encountering this issue when trying to retrieve data with this call. |
I have met the same problem. |
I have encountered this same error intermittently over the last year or so, usually involving some but not all stocks. Today (Sept 28, 2024) it involves all stocks. I can only speak to error-handling right now. Here's how I handle the error: from kill_timeout import kill_timeout .... ############################ HELPER FUNCTIONS ######################################## I import kill_timeout and use it to decorate a helper function, which attempts the actual download, giving the application 15 seconds to complete this task. I log the error when the exception occurs, moving on to the next stock. |
There is a bug in /lib/python3.11/site-packages/yfinance/cache.py Look at this block of code around line 374:
data.fetch_date should be a datetime object, but it is actually a string. Of course you cannot subtract a string from a datetime object. Here is my corrected version of the code:
|
Here's what I am trying to do:
After a long wait of some 20 minutes I get the following error message:
TypeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 data = yahoo_financials.get_historical_price_data("2024-03-01", "2024-03-26", "daily")
File D:\Programs\Anaconda3\envs\quant\lib\site-packages\yahoofinancials\yf.py:163, in YahooFinancials.get_historical_price_data(self, start_date, end_date, time_interval)
161 end = self.format_date(end_date)
162 hist_obj = {'start': start, 'end': end, 'interval': interval_code}
--> 163 return self.get_stock_data('history', hist_obj=hist_obj)
File D:\Programs\Anaconda3\envs\quant\lib\site-packages\yahoofinancials\data.py:631, in YahooFinanceData.get_stock_data(self, statement_type, tech_type, report_name, hist_obj)
629 if isinstance(self.ticker, str):
630 dict_ent = self._retry_create_dict_ent(self.ticker, statement_type, tech_type, report_name, hist_obj)
--> 631 data.update(dict_ent)
632 else:
633 if self.concurrent:
TypeError: 'NoneType' object is not iterable
I have tried other tickers and the result is the same.
The text was updated successfully, but these errors were encountered: