Closed bala-v closed 2 months ago
Where's the bad data proof? Prove Yahoo should be returning something.
Thanks @ValueRaider. On individual stock it seems to work for example
In [2]: msft = yf.Ticker('MSFT').info
In [3]: msft
Out[3]:
{'address1': 'One Microsoft Way',
'city': 'Redmond',
'state': 'WA',
'zip': '98052-6399',
'country': 'United States',
But the previous one on sp500
is returning error and not sure if it is related to your fix in https://github.com/ranaroussi/yfinance/commit/c9680d1396b8517ba4119a046b15dac3eb2c989d
Focus on sp500. Focus on Yahoo.com website.
@bala-v, did this code ever work before?
^GSPC
Tickers
works by passing through a list / string of tickers, not index name. https://github.com/ranaroussi/yfinance/wiki/TickersThanks @ericpien and @ValueRaider I see the problem. I think code should have never worked.
@bala-v How can the bug form be improved? It currently says this near top:
Then visit finance.yahoo.com and confirm they have the data you want
@ValueRaider I would think a handy addition to the bug template would be a curl script to make the same call that users can run outside to see if api is returning and if not it would lead them to infer that it could be the ticker or api call. The pdb function of ipython doesn't allow for tracing the actual request/response. The curl script below is what I tried to simulate the problem but gives a valid unauthorized error due to crumb being incorrect -
% curl -X GET \
'https://query2.finance.yahoo.com/v10/finance/quoteSummary/SP500?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=SP500&crumb=gOzcFykBslr' \
-H 'authority: query2.finance.yahoo.com' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: "Google Chrome";v="93", "Not/Advanced";v="1", "Chromium";v="93"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36' \
-H 'accept: */*' \
-H 'sec-fetch-site: same-site' \
-H 'sec-fetch-mode: no-cors' \
-H 'sec-fetch-dest: empty' \
-H 'accept-language: en-US,en;q=0.9' \
--compressed
{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}%
How would the curl script know what Ticker
attribute the user is requesting? Seems complex. I thought just visiting finance.yahoo.com is easier.
How would the curl script know what Ticker attribute the user is requesting? Seems complex. I thought just visiting finance.yahoo.com is easier.
IMO, since yahoo keeps changing stuff under the hood, though it is easier to visit the site, it might be helpful to have some tracing (e.g --debug) that allows for tracing the call that requests library is making underneath.
Describe bug
yahoo api seems to have changed in v10
Simple code that reproduces your problem
Debug log
404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/SP500?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=SP500&crumb=EMn.pSvuZAp
Bad data proof
No response
yfinance
version0.2.43
Python version
3.11.1
Operating system
mac