Skip to content
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_earnings_dates slow #1939

Open
billionpan2020 opened this issue May 17, 2024 · 0 comments
Open

get_earnings_dates slow #1939

billionpan2020 opened this issue May 17, 2024 · 0 comments

Comments

@billionpan2020
Copy link

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
sourse code

this is the debug window showiing when the code running the method 'controled_get_earnings_datas()':
time out error

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

@ValueRaider ValueRaider changed the title yfinance 0.2.38 is running so slow and raise exception since long time no return get_earnings_dates slow May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant