yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Add cookies as a workaround to fix earnings dates

Open ForeverZyh opened this issue 1 year ago • 1 comments

As discussed in #1932 , it seems we need to login to apply the filter, so the idea is to add additional cookies to the API. Usage:

yf.Ticker(symbol).get_earnings_dates(add_cookies={
        'T': Your_cookies1,
        'Y': Your_cookies2})

I tested that if we supply T and Y cookies to the requests.get, we can successfully get the desired response.

I asked ChatGPT to see how to get my cookies manually: https://chatgpt.com/share/67453e22-bba0-8013-9d97-b8d320b7e24f in Chrome.

ForeverZyh avatar Nov 26 '24 03:11 ForeverZyh

add_cookies should be higher and pass to data.py. At least up to the Ticker class, and maybe on yfinance itself.

And save it in cache via YfData._save_cookie_basic or a similar function, because manually extracting cookie sounds annoying.

ValueRaider avatar Nov 26 '24 21:11 ValueRaider