yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Can't Load info for any Symbol with an .L suffix, eg. MOAT.L, SMH.L, IUFS.L etc

Open podulator opened this issue 1 year ago • 3 comments

Describe bug

After making a request similar to response = yf.Tickers(tickers = symbol_list) where symbol_list is something like : [ "AMZN", "AAPL", "GOOG", "MOAT.L" ] The first 3 lazy load perfectly, but anything with a .L suffix throws

Simple code that reproduces your problem

symbol_list : list[str] = [ "MOAT.L" ] response = yf.Tickers(tickers = symbol_list) print(response.tickers["MOAT.L"]).info["currentPrice"])

Debug log

DEBUG    get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/SMH.L
DEBUG    Entering get()
DEBUG     url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/SMH.L
DEBUG     params={'modules': 'financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': 'SMH.L'}
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 = '6qi6bolK9lT'
DEBUG      Exiting _get_cookie_and_crumb_basic()
DEBUG     Exiting _get_cookie_and_crumb()
DEBUG     response code=200
DEBUG    Exiting get()
DEBUG    Entering get()
DEBUG     url=https://query1.finance.yahoo.com/ws/fundamentals-timeseries/v1/finance/timeseries/SMH.L?symbol=SMH.L&type=trailingPegRatio&period1=1691712000&period2=1707523200
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

yfinance-0.2.36

Python version

Python 3.11.6

Operating system

Garuda / Arch

podulator avatar Feb 09 '24 19:02 podulator

I've noticed this too, not sure where fault lies between Yahoo and yfinance.

ValueRaider avatar Feb 09 '24 19:02 ValueRaider

Oddly this problem for some but not all tickers for me. For example, IKSA.L is a relatively small, obscure ETF and the data seems fine going back 5 years. But SWDA.L which a huge, well-known ETF doesn't return 200 days of complete data.

vlookupRocks avatar Feb 15 '24 18:02 vlookupRocks

I have a script where I iterate through the 503 companies in the S&P500 and in mine I had to replace the '.' in any symbol that had one with a hyphen character '-'. If it works for the companies in the S&P500 that have dots ('.') it should work for any other symbol that has one as well.

*If you have multiple tickers you need to do this to you can put them all in one long string with the symbols separated by spaces and use a list comprehension to replace the dots ('.') with dashes ('-') (and turn the string into a list).

Example: ticker_list_string = 'BRK.B BBY BIO BSX BMY BRO BF.B' ticker_list_hyphenated = [symbol.replace('.', '-') for symbol in ticker_list_string.split()]

csirick2020 avatar Jun 06 '24 19:06 csirick2020