yfinance
yfinance copied to clipboard
some errors are not `raise`d, but rather `print`ed
- Simple code that reproduces your problem when requesting a non-existing ticker symbol, the history method does not handle it as an error, but just a print output. Therefore, since no error is raised, error handling using try and except is not possible. For example:
import yfinance as yf
# trying a ticker that does not exist
ticker = yf.Ticker('T1XN')
try:
ticker.history(period='max')
except:
print("not found")
- The error message
Got error from yahoo api for ticker T1XN, Error: {'code': 'Not Found', 'description': 'No data found, symbol may be delisted'}
- T1XN: No data found for this date range, symbol may be delisted
The error message is not actually an error message!
right now the error is a print
output rather than raise
yfinance has always handled errors like this, I don't know why that decision was made because before me. But I've added a new argument raise_errors
to 0.2 to actually throw Exceptions.
@ValueRaider okay thank you for quick response! I guess this issues can be closed now!
For me, raise_errors has no effect here at all. Errors are just printed, not great when using tqdm to show progress.
@misantroop What ticker prints an error? Any ticker so we can reproduce.