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

fast_info returning error on non available quotes #1951

Open
uzala92 opened this issue May 29, 2024 · 0 comments
Open

fast_info returning error on non available quotes #1951

uzala92 opened this issue May 29, 2024 · 0 comments

Comments

@uzala92
Copy link

uzala92 commented May 29, 2024

Describe bug

I have seen that fast info when passed a ticker that is not currently available, an error occurs due to the reading of non-existing parameters, in this case, currency.

Simple code that reproduces your problem

import yfinance as yf

stock = yf.Ticker("FDQ.BE")

stock.get_fast_info() # same with stock.fast_info

Debug log

Traceback (most recent call last):
File "/home/user/code/src/functions.py", line 11, in get_info_data
fast_info = stock.get_fast_info()
File "/home/user/code/venv/lib/python3.10/site-packages/yfinance/scrapers/quote.py", line 165, in getitem
return getattr(self, k)
File "/home/user/code/venv/lib/python3.10/site-packages/yfinance/scrapers/quote.py", line 255, in currency
self._currency = md["currency"]
KeyError: 'currency'

Bad data proof

I think it could be easily solved by doing .get() of the dictionary. Knowing that all the response parameters have a default value of None, the get() would make them keep the None value and return a dictionary with those parameters to None as the user expects instead of throwing an error.

yfinance version

0.2.40

Python version

3.10.12

Operating system

Ubuntu 22.04

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