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

Incorrect output for YFxxx exceptions #2251

Open
detlefm opened this issue Jan 31, 2025 · 2 comments
Open

Incorrect output for YFxxx exceptions #2251

detlefm opened this issue Jan 31, 2025 · 2 comments

Comments

@detlefm
Copy link

detlefm commented Jan 31, 2025

Describe bug

For YFxxx exceptions the output is:

1 Failed download:
['QUATSCH']: YFPricesMissingError('$%ticker%: possibly delisted; no price data found  (period=1d) (Yahoo error = "No data found, symbol may be delisted")')

I suspect the intended output is

1 Failed download:
YFPricesMissingError('$['QUATSCH']: possibly delisted; no price data found  (period=1d) (Yahoo error = "No data found, symbol may be delisted")')

The error is in multi.py, function download
instead of

for err in errors.keys():
    logger.error(f'{errors[err]}: ' + err)

it should be

for err in errors.keys():
    logger.error(err.replace('%ticker%',errors[err])

Simple code that reproduces your problem

import yfinance as yf

df = yf.download(tickers=["MSF.DE", "QUATSCH"], period="1d", progress=False)

Debug log

DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG MSF.DE: Yahoo GET parameters: {'range': '1d', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/MSF.DE
DEBUG params={'range': '1d', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = '0DlVzIFi41Z'
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG MSF.DE: yfinance received OHLC data: 2025-01-31 16:36:23 only
DEBUG MSF.DE: OHLC after cleaning: 2025-01-31 17:36:23+01:00 only
DEBUG MSF.DE: OHLC after combining events: 2025-01-31 00:00:00+01:00 only
DEBUG MSF.DE: yfinance returning OHLC: 2025-01-31 00:00:00+01:00 only
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Entering history()
DEBUG Entering _fetch_ticker_tz()
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/QUATSCH
DEBUG params=frozendict.frozendict({'range': '1d', 'interval': '1d'})
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=404
DEBUG toggling cookie strategy basic -> csrf
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'csrf'
DEBUG Entering _get_crumb_csrf()
DEBUG loaded persistent cookie
DEBUG Failed to find "csrfToken" in response
DEBUG Exiting _get_crumb_csrf()
DEBUG toggling cookie strategy csrf -> basic
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = '0DlVzIFi41Z'
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=404
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG Got error from yahoo api for ticker QUATSCH, Error: {'code': 'Not Found', 'description': 'No data found, symbol may be delisted'}
DEBUG Exiting _fetch_ticker_tz()
DEBUG Entering history()
DEBUG QUATSCH: Yahoo GET parameters: {'range': '1d', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/QUATSCH
DEBUG params={'range': '1d', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=404
DEBUG toggling cookie strategy basic -> csrf
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'csrf'
DEBUG Entering _get_crumb_csrf()
DEBUG loaded persistent cookie
DEBUG Failed to find "csrfToken" in response
DEBUG Exiting _get_crumb_csrf()
DEBUG toggling cookie strategy csrf -> basic
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = '0DlVzIFi41Z'
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=404
DEBUG Exiting _make_request()
DEBUG Exiting get()
ERROR
1 Failed download:
ERROR ['QUATSCH']: YFPricesMissingError('$%ticker%: possibly delisted; no price data found (period=1d) (Yahoo error = "No data found, symbol may be delisted")')
DEBUG ['QUATSCH']: Traceback (most recent call last):
File "C:\Users\meyer\Projects\Github\Current\meindepot.venv\Lib\site-packages\yfinance\multi.py", line 272, in _download_one
data = Ticker(ticker).history(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\meyer\Projects\Github\Current\meindepot.venv\Lib\site-packages\yfinance\utils.py", line 104, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\meyer\Projects\Github\Current\meindepot.venv\Lib\site-packages\yfinance\base.py", line 81, in history
return self._lazy_load_price_history().history(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\meyer\Projects\Github\Current\meindepot.venv\Lib\site-packages\yfinance\utils.py", line 104, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\meyer\Projects\Github\Current\meindepot.venv\Lib\site-packages\yfinance\scrapers\history.py", line 245, in history
raise _exception
yfinance.exceptions.YFPricesMissingError: $%ticker%: possibly delisted; no price data found (period=1d) (Yahoo error = "No data found, symbol may be delisted")

DEBUG Exiting download()

Bad data proof

No bad data

yfinance version

0.2.52

Python version

3.12.8

Operating system

Windows 11

@ValueRaider
Copy link
Collaborator

ValueRaider commented Jan 31, 2025

It makes more sense when multiple tickers are invalid:

>>> yf.download(tickers=["MSF.DE", "QUATSCH", 'QUATSCH1'], period="1d", progress=False)

2 Failed downloads:
['QUATSCH', 'QUATSCH1']: YFPricesMissingError('$%ticker%: possibly delisted; no price data found  (period=1d) (Yahoo error = "No data found, symbol may be delisted")')

It's grouping tickers with the same error. Maybe the $%ticker%: part is redundant.

@detlefm
Copy link
Author

detlefm commented Jan 31, 2025

Sorry, but that's not my point. A few lines before, the placeholder %ticker% is introduced. And it is not filled, but the list is written in front of the actual log entry with the description of the requested tickers and the problem.
If '$%ticker' were not there, it might make sense - to me, it looks like an oversight.
I would expect:

['QUATSCH', 'QUATSCH1']: YFPricesMissingError( possibly delisted; no price data found (period=1d) (Yahoo error = "No data found, symbol may be delisted")')
or
YFPricesMissingError('[QUATSCH', 'QUATSCH1'], possibly delisted; no price data found (period=1d) (Yahoo error = "No data found, symbol may be delisted")')
But if that was the intention - OK.

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

2 participants