ranaroussi / yfinance

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

No data found, symbol may be delisted #359

Closed TimurNurlygayanov closed 1 year ago

TimurNurlygayanov commented 4 years ago

Hi, thank you for the really useful library!

My code:

data = yf.download(' '.join(TICKERS), start=START_DATE, end=END_DATE,
                                 group_by='ticker')

Sometimes during the downloading of the historical data, I can see some errors like:

- ACHN: No data found, symbol may be delisted
- BID: No data found, symbol may be delisted
- ECA: No data found, symbol may be delisted

So, I suggest we add retry option to try download the data one more time in case it failed. Now I'm doing this workaround in my code:

data = yf.download(' '.join(TICKERS), start=START_DATE, end=END_DATE,
                   group_by='ticker')

tickers_to_retry = []

for ticker in TICKERS:
    download_success = [r for r in data[ticker]['Close'] if r > 0]
    if download_success:
        CASHED_DATA[ticker] = {'close': [r for r in data[ticker]['Close']],
                               'row_data': data[ticker],
                               'low': [r for r in data[ticker]['Low']],
                               'high': [r for r in data[ticker]['High']]}
    else:
        tickers_to_retry.append(ticker)

if tickers_to_retry:
    data = yf.download(' '.join(tickers_to_retry), start=START_DATE, end=END_DATE,
                       group_by='ticker')

for ticker in tickers_to_retry:
    download_success = [r for r in data[ticker]['Close'] if r > 0]
    if download_success:
        CASHED_DATA[ticker] = {'close': [r for r in data[ticker]['Close']],
                               'row_data': data[ticker],
                               'low': [r for r in data[ticker]['Low']],
                               'high': [r for r in data[ticker]['High']]}

So it is better to have retry inside the library and do them automatically at least once.

TimurNurlygayanov commented 4 years ago

Note: it also doesn't help me, but every day I can see different tickers in "delisted" status, and next day these tickers downloading just fine.

danlinenberg commented 4 years ago

Getting it too but the issue is with Yahoo's API rather than this library. I've found 1000+ tickers that display this behaviour, retrying doesn't really work.

jtilson commented 4 years ago

I am having the same problem. It happens to me to such an extent that the software overall is not helping me. I hope someone can identify a solution. Maybe need to put in a pause or ?

jtilson commented 4 years ago

Well, I've been working with yfinance now for a few days and for my purposes, I find it to not be useful. I think the marketing of a "reliable" stock reader is untrue. This code randomly fails to fetch me data a large % of the time. I will not spend time trying quantify the many number of ways it fails. I would simply say, try to download 3,000 tickers at one time and tell us how it goes. Doesn't matter if you use threads or not, chunk up tickers into sublists, or not, etc. You will find occasionally (and inconsistently) tickers being declared delisted. Also, at select times ( occasionally) you may get Nans which if you try to read later works fine. I need something that is actually reliable.

dpguthrie commented 4 years ago

It looks like Yahoo Finance (YF) has started to block requests like these by showing 404 errors; that's why you continue to see "No data found, symbol may be delisted". I've written a YF library that has a built-in retry mechanism as well as a backoff_factor for each successive retry. I was successful retrieving daily YTD data for all Nasdaq tickers. You can see here: https://gist.github.com/dpguthrie/120aeca5bd644cf50fd98b344a307297

jtilson commented 4 years ago

Thank you for your help. I really wish for yfinance to work for me but the behavior seems even more erratic that I first thought . ( Of course I am not blaming yfinance but that is not material to me) . For example, suppose I have a list of 100 nasdaq tickers. I break them up into chunks of 4 (at most). Time ranges from now to 180 days past. Sometimes a chunk will have a missing entry, which I can believe is rather random event but 'WK" is almost always "lost" unless I call it as a singleton. So the probability of loss seems ticker dependent.

mspacey4415 commented 4 years ago

I'm also getting these even on small batches. Wondering if there are certain times of the day that Yahoo just don't work?

tickers =['FNF', 'ASML', 'GOOGL', 'CVS'] data = yf.download(tickers, group_by="ticker", period='1y')

2 Failed downloads:

jtilson commented 4 years ago

I was wondering the same thing regarding time of day, etc. I agree that the newer library is more resilient. Thanks! But I tend to do bulk downloads ( ~ 3000 tickers) and I experience a pretty high failure rate. I have toggled asynchronous and also do one ticker at a time, now. That seems to help. But, what occurs now, pretty often, for a (for example) 180 day time range, "histories" will only return the last ("now") price. For some reason "WK" is particularly susceptible.

I may have to go old school and put some wait steps into my code. But that will dramatically increase the total execution time. jeff


Jeffrey Tilson

Senior Research Scientist

Renaissance Computing Institute

UNC Chapel Hill

(919) 445-9657


From: mspacey4415 notifications@github.com Sent: Wednesday, July 29, 2020 12:58 AM To: ranaroussi/yfinance yfinance@noreply.github.com Cc: Tilson, Jeffrey L jtilson@renci.org; Comment comment@noreply.github.com Subject: Re: [ranaroussi/yfinance] No data found, symbol may be delisted (#359)

I'm also getting these even on small batches. Wondering if there are certain times of the day that Yahoo just don't work?

tickers =['FNF', 'ASML', 'GOOGL', 'CVS'] data = yf.download(tickers, group_by="ticker", period='1y')

2 Failed downloads:

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ranaroussi/yfinance/issues/359#issuecomment-665431091, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB6PWABKDQPI7EBPPZL5RKDR56T7HANCNFSM4OJ4R5VQ.

100330706 commented 4 years ago

2000 requests/ hour per IP might be what is killing us - https://stackoverflow.com/questions/9346582/what-is-the-query-limit-on-yahoos-finance-api

danlinenberg commented 4 years ago

I haven't experienced this issue today, maybe it was fixed. Can anyone confirm?

mssrr commented 3 years ago

though not sure related to above, I received the error due to no trading day, so no data, and it return empty dataframe. 5105.KL: No data found for this date range, symbol may be delisted

so it possible to happen due to stock temporary suspend,no trade, etc.

jeames00 commented 3 years ago

I've only experienced this issue when connected to a VPN. Change the VPN country or disconnect and yfinance works OK.

Blessvskp commented 3 years ago

I am getting the same error even to download data for a single symbol! I tried several times giving time gap. But in vain!

R=yf.Ticker('CAPACITE') R.history(start='2021-08-25',end='2021-08-27', actions=False) CAPACITE: No data found, symbol may be delisted Empty DataFrame Columns: [Open, High, Low, Close, Adj Close, Volume] Index: [ ]

This is indeed a big nuisance.

Please help

deadskull7 commented 2 years ago

Hi, thank you for the really useful library!

My code:

data = yf.download(' '.join(TICKERS), start=START_DATE, end=END_DATE,
                                 group_by='ticker')

Sometimes during the downloading of the historical data, I can see some errors like:

- ACHN: No data found, symbol may be delisted
- BID: No data found, symbol may be delisted
- ECA: No data found, symbol may be delisted

So, I suggest we add retry option to try download the data one more time in case it failed. Now I'm doing this workaround in my code:

data = yf.download(' '.join(TICKERS), start=START_DATE, end=END_DATE,
                   group_by='ticker')

tickers_to_retry = []

for ticker in TICKERS:
    download_success = [r for r in data[ticker]['Close'] if r > 0]
    if download_success:
        CASHED_DATA[ticker] = {'close': [r for r in data[ticker]['Close']],
                               'row_data': data[ticker],
                               'low': [r for r in data[ticker]['Low']],
                               'high': [r for r in data[ticker]['High']]}
    else:
        tickers_to_retry.append(ticker)

if tickers_to_retry:
    data = yf.download(' '.join(tickers_to_retry), start=START_DATE, end=END_DATE,
                       group_by='ticker')

for ticker in tickers_to_retry:
    download_success = [r for r in data[ticker]['Close'] if r > 0]
    if download_success:
        CASHED_DATA[ticker] = {'close': [r for r in data[ticker]['Close']],
                               'row_data': data[ticker],
                               'low': [r for r in data[ticker]['Low']],
                               'high': [r for r in data[ticker]['High']]}

So it is better to have retry inside the library and do them automatically at least once.

Hey you have to add an extension at the end of the ticker like here in India its 'NS' for NSE (stock exchange). So example 'RELIANCE' is a ticker on NSE so, if I do just yf.Ticker("RELIANCE"). It will do nothing and show the same error but if I do yf.Ticker("RELIANCE.NS"). Its working flawlessly.

asafravid commented 2 years ago

Ticker names must be the yahoo finance link ones so you initially must have placed.ns I don’t think it a yfinance issue It’s simple the way the yahoo finance website assigned ticker names For instance TASE tickets are with .ta suffix

Sourabhwitho commented 1 year ago

Try using a proper suffix at the end of your tickets, for example, the NSE index has the '.NS' suffix at the end.

babak3548 commented 1 year ago

I get same error only in Pycharm. But same code work on Jupyter

ValueRaider commented 1 year ago

Is this fixed in latest release 0.2.17?