ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.96k stars 2.45k forks source link

Strange error for a specific symbol #1901

Closed synergiator closed 7 months ago

synergiator commented 7 months ago

Describe bug

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.

Simple code that reproduces your problem

ticker_data = yf.Ticker("RAD")

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 version

0.2.37

Python version

3.11.2

Operating system

Debian 12

subhammoda commented 7 months ago

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.