get_earnings_dates slow
billionpan2020 opened this issue · comments
Describe bug
Beside the issue #1938 that I just reported, I found another issue that seldom occured in the past.
the get_earnings_dates() method return data apparently slower than before and because of that reason, the get_earnings_dates() method always raise exception for being not able to retrieve data successfully, but when I triger this method in the jupyter notebook, it did successfully retrieve the data after waiting for a long time.
Simple code that reproduces your problem
here is the exception raised by get_earnings_dates() method which catched by my code.
this attachment is the sourse code
this is the debug window showiing when the code running the method 'controled_get_earnings_datas()':
Sorry the program notes writen in Chinese, in order to make it read easier I translate some key notes in English, here is the translation:
source code**
access the earnings data in a controled speed in order not to make the server overload
def controled_get_earnings_datas(stock,max_num):
global G_EARNINGS_DATA_ACCESS_NUM
try:
earnings = stock.get_earnings_dates(limit=max_num)
G_EARNINGS_DATA_ACCESS_NUM += 1
# control API access rate
if G_EARNINGS_DATA_ACCESS_NUM > 50:
print(f"{BLUE}access get_earnings_dates method reach 50 times,program pause running 1 minute...{RESET}")
time.sleep(1 * 60)
G_EARNINGS_DATA_ACCESS_NUM = 0
return earnings
except Exception as e:
info=f"--{stock.ticker}--yfinance method get_earnings_dates() raise exception: {e}"
add_to_logfile(info)
print(f"{RED}{info}{RESET}")
print(f"{BLUE}Program temporarily pause running 1 minutes{RESET}")
time.sleep(1 * 60)
return None
end code****************
Debug log
--EMR--yfinance 函数get_earnings_dates()抛异常: HTTPSConnectionPool(host='finance.yahoo.com', port=443): Read timed out.
Bad data proof
No response
yfinance
version
0.2.38
Python version
No response
Operating system
No response