Open lucas03 opened 10 months ago
Already has a second strategy for if first fails but never used if YF blows up. See if you can add handling for that error.
Hmm, I don't really understand that code part and not sure how that urllib ReadTimeoutError
is mapped to requests error?
When I tried to read that strategy code, it already fails on second try (under if response.status_code >= 400
). 😕
There are also issues with yahooquery
. See fc.yahoo.com not responding. You might try using finance.yahoo.com
instead of fc.yahoo.com
.
@lucas03 Copy the if-statement
from line #353 to #377. Should fix exception but I expect data fetch will fail because cookie fetch failed.
The cycling is messy because needs to handle concurrent threads. But hopefully clear enough to add a third strategy.
I was able to get this working with the basic cookie strategy by disabling retrieval of cached cookies, changing the domain from fc.yahoo.com to guce.yahoo.com/consent, and then handling the redirect by choosing the original response in the response.history. Make these changes in yfinance/data.py: L146 -> if cookie_dict['age'] > datetime.timedelta(days=0): L163: -> url='https://guce.yahoo.com/consent', L168 -> if len(response.history) > 0: response = response.history[0]
@roscherr #1084
@roscherr did first two steps in version '0.2.36' and this solved the issue for me.
Describe bug
I can not reproduce on my local macbook, but on my hetzner server I see a lot of timeouts to fc.yahoo.com. I found an issue that says fc.yahoo.com got to some blacklist?
Would it be possible to use different domain for getting the cookie. Possibly make retries and timeout configurable?
Simple code that reproduces your problem
Debug log
Bad data proof
No response
yfinance
version0.2.33
Python version
3.11.6
Operating system
python:3.11.6-slim-bookworm