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
KeyError: 'exchangeTimezoneName' when accessing ticker history #1076
Comments
What is "AFN"? I don't see it in Yahoo. And the old price data looks bad - 0 volume, low=high. |
The example above is actually from the London Stock Exchange. I found that using "AFN.L" it returns data and doesn't raise an exception . So it seems the exception in the new release happens for invalid tickers. If I enter ticker "???" in the new release I get the key error exception. In the previous version there was no key error, just a printed message:
|
That's a good point, it should print a nice message. Will fix for next release. |
hey, i got the same error. it used to print BEFORE: KGF.L 1 Failed download:
NOW: raises error and hangs like this when i loop trough the ticker symbols. not fixable with try/except KGF.L hoping for a fix soon, thanks for your work and help |
Should be fixed now |
@c0mm0d0re What ticker is generating error? I am getting correct behaviour for both listed and delisted tickers. |
I'm not going to run every ticker in the universe and get my IP blocked/restricted. Just tell me what ticker failed for you. Also quicker this way. |
…id of multiple calls to self.info (get_info).
I'm having the same issue (using the dev branch)
However as info is backed by a property function (defined in the subclass) and calls self.get_info (defined in base class) it probably does multiple requests and the self.info can differ.
I updated the code in my forked dev branch so the KeyError exception issue should not be triggerd. However, the fact that the code get different results from consecutive calls to self.get_info() is the root cause of this bug and not something my code change fixes My Traceback:
|
It does make multiple requests but only the first does work. All subsequent requests will quickly return: Line 362 in 34dfe94
Were you able to reliably produce 'different results from consecutive calls'? |
That depends: Line 358 in 34dfe94
The get info does a lot of requests and if some of them fails in the first call that set self._info , self._sustainability or self._recommendations then all requests are redone if I read the code correctly.
|
Have now tired to understand the code a bit more. |
I understand now. Changing that if-statement from |
I created a #1109 with my fix, it does however not use |
@ValueRaider I looked at the json result we get from the endpoint that gets history ticker data |
At that point in the code, where start & end dates being processed, the price request hasn't been sent. |
Yes, but would it not be better to use that endpoint (giving a minimal period) to get the timezone?
Using query2 would give a speedup of 10 times. And the extra query to ticker data could be avoided completely for longer ticker timeintervals (>1d) by asking for an extra day before and after and do the timezone filtering of the returned data. |
Good point. I'll push an update to |
If you are going to do multiple request to query2 to get the timezone maybe the code that does the request should be refactored in order to be reused. I noted that this try/except clause effectively negates the explicit raising of runtime error to inform about yahoo is down. What is the desired behaviour? Code like this seems very ambiguous error prone to me. |
So that Regarding timezone - I've pushed to |
Can everyone update to 0.1.84 then report on the status of the bug? Is it solved? |
Seems solved for me. |
Current yfinance 0.1.75 raises an exception when running the following:
Running the same sample against the previous release returns:
If I run with
threads=True
it will raise the exception and hang.The text was updated successfully, but these errors were encountered: