Same code used interchangeably in sequence works for AAPL but not for RAD.
Call:
ticker_data = yf.Ticker(symbol)
Error:
404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/RAD?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=RAD&crumb=gIjxtRwkeT3
In the log I see a 200 code after a 404 but in Python code I can catch an exception.
It does not work as "RAD" is not a symbol in yahoo finance. In yahoo finance the symbol is "RADCQ". You will have to use symbols that are present on yahoo finance.
Describe bug
Same code used interchangeably in sequence works for AAPL but not for RAD.
Call:
Error:
In the log I see a 200 code after a 404 but in Python code I can catch an exception.
Simple code that reproduces your problem
Debug log
DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/RAD DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/RAD DEBUG params={'modules': 'financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': 'RAD'} 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 = 'gIjxtRwkeT3' 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 = 'gIjxtRwkeT3' DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=404 DEBUG Exiting get() ERROR 404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/RAD?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=RAD&crumb=gIjxtRwkeT3 DEBUG Entering get() DEBUG url=https://query1.finance.yahoo.com/ws/fundamentals-timeseries/v1/finance/timeseries/RAD?symbol=RAD&type=trailingPegRatio&period1=1696896000&period2=1712707200 DEBUG params=None 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=200 DEBUG Exiting get()
Bad data proof
No response
yfinance
version0.2.37
Python version
3.11.2
Operating system
Debian 12