Catching errors printed by yfinance.download #2083
Replies: 2 comments
-
Hello, I want the community know i found a workaround that worked for me. Here is the link For to catch the error of yfinance.download() you can import the shared.py from yfinance in your code. It's where are the yfinance errors printed as it seems. Hope this help, but it's a workaround.
The output will be like this: |
Beta Was this translation helpful? Give feedback.
-
Duplicate of #1832 |
Beta Was this translation helpful? Give feedback.
-
Hello all, there is a way to catch the error printed by yfinance.download? I did some research but found nothing on this.
I think would be useful have the possibility to catch and manage the errors generated by the download method.
An example to clarify:
When i try to download on a period of 5 years the LAC ticker (Lithium Americas Corp) i get the following message printed in the terminal.
[100%**] 1 of 1 completed
1 Failed download:
['LAC']: YFInvalidPeriodError("%ticker%: Period '5y' is invalid, must be one of ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', 'ytd', 'max']")
And it's correct because LAC was founded in the 2023, so there not exist 5 years of data. But I have no way to make my code react and manage starting from this error.
Beta Was this translation helpful? Give feedback.
All reactions