Skip to content

Conversation

@JTarball
Copy link

download() has no raise_errors flag which seems like an oversight

#1832

I have added 'raise_errors' and 'raises' if you need granular exception raises e.g. only the rate limiting exception

@JTarball JTarball closed this Apr 11, 2025
@JTarball JTarball reopened this Apr 11, 2025
@ValueRaider
Copy link
Collaborator

What happens when two different tickers throw different exceptions?

@JTarball
Copy link
Author

JTarball commented Apr 13, 2025

Should raise them separately

In this example test raises=[YFException] which is the base exception .. so all are raised.

Note it will still logger the error also, I assume thats ok.

e.g.

  • YFPricesMissingError**: $EGS745W1C011.CA
  • YFTzMissingError**: $9519.SR:

{"timestamp":"2025-04-13 09:43:12,972","severity":"INFO","name":"test.jobs.prices","message":"-- Processing batch 15 of 3409 --","task_index":"0","task_count":"1","retry_count":"0","component":"shared.envutil"} [**********************84%*************** ] 21 of 25 completedException in thread Thread-399 (_run_via_pool): Traceback (most recent call last): File "/Users/<REDACTED>/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/Users/<REDACTED>/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/multitasking/__init__.py", line 104, in _run_via_pool return callee(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 268, in _download_one_threaded _download_one(ticker, start, end, auto_adjust, back_adjust, repair, File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 297, in _download_one raise exc File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 284, in _download_one data = Ticker(ticker).history( ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper result = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/base.py", line 82, in history return self._lazy_load_price_history().history(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper result = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/scrapers/history.py", line 245, in history raise _exception yfinance.exceptions.**YFPricesMissingError**: $EGS745W1C011.CA: possibly delisted; no price data found (1d 2020-04-13 -> 2025-04-12) [**********************88%***************** ] 22 of 25 completed{"timestamp":"2025-04-13 09:48:21,342","severity":"ERROR","name":"yfinance","message":"Failed to get ticker '9519.SR' reason: 'NoneType' object has no attribute 'name'","component":"shared.envutil"} Exception in thread Thread-393 (_run_via_pool): Traceback (most recent call last): File "/Users/<REDACTED>/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/Users/<REDACTED>/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/multitasking/__init__.py", line 104, in _run_via_pool return callee(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 268, in _download_one_threaded _download_one(ticker, start, end, auto_adjust, back_adjust, repair, File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 297, in _download_one raise exc File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/multi.py", line 284, in _download_one data = Ticker(ticker).history( ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper result = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/base.py", line 82, in history return self._lazy_load_price_history().history(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper result = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/<REDACTED>/Library/Caches/pypoetry/virtualenvs/test-pEPzHlFW-py3.11/lib/python3.11/site-packages/yfinance/scrapers/history.py", line 121, in history raise _exception yfinance.exceptions.**YFTzMissingError**: $9519.SR: possibly delisted; no timezone found [*********************100%***********************] 23 of 25 completed {"timestamp":"2025-04-13 09:48:21,366","severity":"ERROR","name":"yfinance","message":"\n2 Failed downloads:","task_index":"0","task_count":"1","retry_count":"0","component":"shared.envutil"} {"timestamp":"2025-04-13 09:48:21,366","severity":"ERROR","name":"yfinance","message":"['EGS745W1C011.CA']: possibly delisted; no price data found (1d 2020-04-13 -> 2025-04-12)","task_index":"0","task_count":"1","retry_count":"0","component":"shared.envutil"}

@JTarball
Copy link
Author

@ValueRaider anything else you need from me?

@ValueRaider
Copy link
Collaborator

I've pushed a commit that I think make sense, helps with many errors (imagine 10s-100s). Try it:

yf.download(tkrs, raise_errors=True)
yf.download(tkrs, raise_errors='one')

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

Successfully merging this pull request may close these issues.

2 participants