yfinance
yfinance copied to clipboard
"recommendations" empty when the ticker contains a dot
I'm trying to get some info for the AEX index. All of these stocks on Yahoo have the ".AS" suffix. However, when trying to get "recommendations" on these stocks, it always returns an empty array.
some (but not all) stocks are listed on multiple exchanges. An example would be ASML. Getting the recommendations for "ASML" works. Getting recommendations for "ASML.AS" does not.
The Yahoo finance website lists the different recommendations for both stock symbolls: https://finance.yahoo.com/quote/ASML https://finance.yahoo.com/quote/ASML.AS
.\python.exe
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import yfinance as yf nodot = yf.Ticker("ASML") withdot = yf.Ticker("ASML.AS") withdot.recommendations nodot.recommendations Firm To Grade From Grade Action Date 2012-06-21 08:16:00 Bernstein Outperform init 2012-08-28 06:13:00 Deutsche Bank Sell Hold down 2012-09-19 06:40:00 JP Morgan Overweight init 2012-10-09 09:21:00 CLSA Outperform init 2012-10-18 09:52:00 RBC Capital Sector Perform Outperform down ... ... ... ... ... 2021-04-16 14:48:14 Wells Fargo Overweight main 2021-07-16 13:07:40 Wells Fargo Overweight main 2021-09-08 12:04:22 Wells Fargo Overweight main 2021-09-28 10:58:52 New Street Research Neutral Buy down 2021-10-15 10:39:00 Piper Sandler Overweight init
[81 rows x 4 columns]`
It seems that the issue comes from that yfinance.utils.get_json("https://finance.yahoo.com/quote/ASMl.AS/analysis") or yfinance.utils.get_json("https://finance.yahoo.com/quote/ASMl.AS/") don't return anything for the recommendations. 'upgradeDowngradeHistory' is the name used to store the recommendations there.
What is displayed on yahoo finance web page might be sourced from the ASML data and yfinance might have to do the same if it want to support the derived tickers from the different exchanges.
Try switching - for the .
I can't reproduce, does this still happen?