ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
13.15k stars 2.33k forks source link

"regularMarketOpen" is not a key of `self._info` bug #353

Closed siavashadpey closed 1 year ago

siavashadpey commented 4 years ago
t = yf.Ticker("XEF").info
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/yfinance/yfinance/ticker.py", line 138, in info
    return self.get_info()
  File "/home/ubuntu/yfinance/yfinance/base.py", line 416, in get_info
    self._get_fundamentals(proxy)
  File "/home/ubuntu/yfinance/yfinance/base.py", line 319, in _get_fundamentals
    self._info['regularMarketPrice'] = self._info['regularMarketOpen']
KeyError: 'regularMarketOpen'

I got this issue by cloning the master branch with the latest commit being 9cdda84. A possible fix would be to check if "regularMarketOpen" is a key of self._info before accessing it. I didn't investigate too much, but it might be worth checking if the fact that "regularMarketOpen" is not a key of self._info is an expected behaviour or not.

siavashadpey commented 4 years ago

PR #354 should fix this. However the code is failing the codefactor check. I didn't have a chance to check if it's because of my code changes or something else.

jhssilva commented 4 years ago

Any news on this?

fishstoryyy commented 3 years ago

Any news?

siavashadpey commented 3 years ago

@jhssilva, @fishstoryyy: I'm not sure if it has been merged to this branch, but if not you can fork from mine.

alifhughes commented 3 years ago

@bradmetz (tagging you as you were last person to merge, sorry) Any chance this could be looked at? PR: 352 for a fix. I'm also seeing this with JET:


>>> import yfinance as yf
>>> jet = yf.Ticker("JET")
>>> jet.info
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alistair.hughes/Library/Caches/pypoetry/virtualenvs/stockbot-WL9v0jWp-py3.8/lib/python3.8/site-packages/yfinance/ticker.py", line 138, in info
    return self.get_info()
  File "/Users/alistair.hughes/Library/Caches/pypoetry/virtualenvs/stockbot-WL9v0jWp-py3.8/lib/python3.8/site-packages/yfinance/base.py", line 446, in get_info
    self._get_fundamentals(proxy)
  File "/Users/alistair.hughes/Library/Caches/pypoetry/virtualenvs/stockbot-WL9v0jWp-py3.8/lib/python3.8/site-packages/yfinance/base.py", line 340, in _get_fundamentals
    self._info['regularMarketPrice'] = self._info['regularMarketOpen']
KeyError: 'regularMarketOpen'
>>>
detrin commented 3 years ago

Having the same issue with OEDV ticker.

Ghernandez1991 commented 3 years ago

having the same issue. posting my terminal to see if it helps.

Traceback (most recent call last): File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask\app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask\app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask_compat.py", line 39, in reraise raise value File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\flask\app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "app.py", line 63, in secondpage df = divcalc(stock_list, how_much_per_month ) File "C:\Users\Gabriel Hernandez\desktop\stock_app\function.py", line 24, in divcalc most_recent_price = stock_selected.info['previousClose'] File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\yfinance\ticker.py", line 138, in info return self.get_info() File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\yfinance\base.py", line 446, in get_info self._get_fundamentals(proxy) File "C:\Users\Gabriel Hernandez.conda\envs\stock_app\lib\site-packages\yfinance\base.py", line 340, in _get_fundamentals self._info['regularMarketPrice'] = self._info['regularMarketOpen'] KeyError: 'regularMarketOpen' 127.0.0.1 - - [14/Mar/2021 15:55:52] "POST /secondpage HTTP/1.1" 500 -

morganjury commented 3 years ago

Still present today, any updates on when this might get fixed?

import yfinance as yf t = yf.Ticker('SNE') t.info['name'] Traceback (most recent call last): File "", line 1, in File "C:\Users\morga\AppData\Local\Programs\Python\Python39-32\lib\site-packages\yfinance\ticker.py", line 138, in info return self.get_info() File "C:\Users\morga\AppData\Local\Programs\Python\Python39-32\lib\site-packages\yfinance\base.py", line 447, in get_info self._get_fundamentals(proxy) File "C:\Users\morga\AppData\Local\Programs\Python\Python39-32\lib\site-packages\yfinance\base.py", line 340, in _get_fundamentals self._info['regularMarketPrice'] = self._info['regularMarketOpen'] KeyError: 'regularMarketOpen'

It's only on some tickers, however:

t = yf.Ticker('RR.L') t.info['longName'] 'Rolls-Royce Holdings plc' t = yf.Ticker('GOOG') t.info['longName'] 'Alphabet Inc.'

byteatwork commented 3 years ago

Seems the ticker 'SNE' is no longer available in Yahoo

TXMCtrades commented 3 years ago

Has this ever been resolved? I still get 'regularMarketOpen' errors on a fair number of tickers.