ranaroussi / yfinance

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

"No data found, symbol may be delisted" #1268

Closed ChristofNies closed 1 year ago

ChristofNies commented 1 year ago

YFinance Version: Currently 0.2.3, also tried on 0.2.2, 0.2.1 and 0.1.96

Operating System: Windows 11 Enterprise

Code: msft = yf.download(tickers='MSFT', period='1mo', interval='5m') msft

Error: [*100%***] 1 of 1 completed

1 Failed download:

galashour commented 1 year ago

can you print the yfinance version number from the code to make sure it uses the right version?

I'm using 0.2.3 with windows 11 without issues (and worked also with 0.1.94 before that). Also - which version of python are you using?

ChristofNies commented 1 year ago

Yes I added the print line that was in the issue creation info and it used the right version after up- and downgrading the version of yfinance.

I'm new to python and finance with python/data science etc. and I'm following a tutorial on it, so I'm sorry if I don't provide you with the best information. I will try to give you all the context you might need: I installed Python 3.9.13 and afterwards Anaconda. But I'm using the code within a Jupyter Notebook (6.4.12 it says within my navigator) that I run via Anaconda Navigator.

Version screenshot: Versions condaInfo

looper15 commented 1 year ago

I am also getting the same issue

I have used yfinance as an override for PDR but getting

This error

1 F1 Failed download:
- AAPL: No data found for this date range, symbol may be delisted

This is My code

from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()

user_input = st.text_input('Enter Stock Ticker', 'AAPL')

df = pdr.get_data_yahoo(user_input, start="2017-01-01", end="2017-04-30")
display(df)
molecula21 commented 1 year ago

Same here, using version 0.2.3 and I get a "No summary info found, symbol may be delisted" for every symbol. I am using Anaconda + Jupyterlab if that helps, and I updates the yfinance package with pip install yfinance --upgrade --no-cache-dir recently

ValueRaider commented 1 year ago

Can a Jupyter user debug the root cause?

ChristofNies commented 1 year ago

Also tried this solution: #359. But it didn't seem to help

Enigma-song commented 1 year ago

I have the same issue. yfinance-0.2.3;

cwyz-dev commented 1 year ago

Just an observation I'm making based on times of trying a few different tickers, in different markets: I can only access the data for a ticker if I am running the calls while the market is open. I was querying data earlier today (around 12.00 pm MST) for the tickers: RNW.TO, GOOGL, BTCW.V, BA, ORCL, ZDV.TO; but when I was trying just recently (around 3.30 pm MST, after market close) I was unable to get the data. I found no mention of this being the case, so just thought I'd let others know that it might be related.

molecula21 commented 1 year ago

Hey @cwyz-dev, I just observed the same. During market hours I got all the symbols I use to look at (VWCE.DE, VUAA.DE, EQQQ.PA, FGEQ.DE, XAIX.DE, GFEA.DE, SGLD.AS, IQQX.DE) to be fully populated. That happened once. Running the same script a few minutes later yielded the same "No summary info found, symbol may be delisted" for some of them.

molecula21 commented 1 year ago

Is this problem only Jupyter + Anaconda? Has anyone with a different setup had the same issue? I'm still facing the same chalenge, only once in a while my script is able to pick up the entirety of the symbols.

ValueRaider commented 1 year ago

Is this problem only Jupyter + Anaconda?

I only assume this as appears to be common denominator. What is your execution environment?

thomai commented 1 year ago

Same problem here with yfinance 0.2.3. I do not use Jupyter or Anaconda but plain as follows:

print(yf.Ticker(ticker_name).info["regularMarketPrice"])

Output: "No summary info found, symbol may be delisted" for the last few days.

vidalmarco commented 1 year ago

Could it be the same as #1387 i.e. related to cache tz retrieval?

ValueRaider commented 1 year ago

@Vidal4SigurRos Absolutely not because that would print "No timezone found, symbol may be delisted"

Because this issue seems to be affecting tiny % of users, they need to debug and provide some clues if not a fix.

realgauravmehta commented 1 year ago

Any updates on this issue. I am facing this issue as well. The only common factor I am able to observe is that the message "No data found for this date range, symbol may be delisted" is only displayed off market hours. When I try during market hours, my program runs as intended. For further information, I am running a Jupyter Notebook in VS Code.

TapeReaderJoe commented 1 year ago

I did some digging for my problem and added an Exception print in the try-except-clause (base.py lines 673-695), seems like the "localize" call might be the culprit.

'datetime.timezone' object has no attribute 'localize'

I just got the "No data found, symbol may be delisted" for the interval="max", interval="10y" worked fine. Commenting out lines 675-681 in base.py solved my issue for the "max" interval. The read from cache functionality will then not be used, not sure how that will affect the data though.

NOTE: everything worked fine for me until i updated yfinance and pandas. Previous versions pandas==1.3.5 yfinance==0.1.63.

Hope this might be of use for someone!

ValueRaider commented 1 year ago

seems like the "localize" call might be the culprit.

'datetime.timezone' object has no attribute 'localize'

Provide the traceback, so know which call you mean.

Also, when this exception occurs print the object - type & value, of both the date/datetime object and it's tzinfo attribute. I think we're close to a fix, I can smell it.

TapeReaderJoe commented 1 year ago

seems like the "localize" call might be the culprit.

'datetime.timezone' object has no attribute 'localize'

Provide the traceback, so know which call you mean.

Also, when this exception occurs print the object - type & value, of both the date/datetime object and it's tzinfo attribute. I think we're close to a fix, I can smell it.

https://github.com/ranaroussi/yfinance/blob/1edeaf07dc8ea9129e37f08dc770c1e3a16f431f/yfinance/base.py#L654

ValueRaider commented 1 year ago

I think fix is this: replace this line:

https://github.com/ranaroussi/yfinance/blob/1edeaf07dc8ea9129e37f08dc770c1e3a16f431f/yfinance/base.py#L654

with this:

dt_now = pd.Timestamp.utcnow()

Try that and report back

YUYANGSHEN commented 1 year ago

dt_now = pd.Timestamp.utcnow()

it doesn't work

YUYANGSHEN commented 1 year ago

I have the duplicated error “No timezone found, symbol may be delisted”. how to solve it?

YUYANGSHEN commented 1 year ago

I have the duplicated error “No timezone found, symbol may be delisted”. how to solve it?

Note: I use a proxy to access the internet

ValueRaider commented 1 year ago

I have the duplicated error “No timezone found, symbol may be delisted”. how to solve it?

No idea. You have to debug

TapeReaderJoe commented 1 year ago

I think fix is this: replace this line:

https://github.com/ranaroussi/yfinance/blob/1edeaf07dc8ea9129e37f08dc770c1e3a16f431f/yfinance/base.py#L654

with this:

dt_now = pd.Timestamp.utcnow()

Try that and report back

That solved my issue, ty!

ValueRaider commented 1 year ago

@TapeReaderJoe Can you submit a Pull Request? #1084

YUYANGSHEN commented 1 year ago

@TapeReaderJoe Can you submit a Pull Request? #1084

I have solved this issue through replace the main branch by the proxy fixed branch. thx

YUYANGSHEN commented 1 year ago

I have the duplicated error “No timezone found, symbol may be delisted”. how to solve it?

No idea. You have to debug

thx guys. I have solved this issue just replace by a right branch

KevinYew97 commented 1 year ago

dt_now = pd.Timestamp.utcnow()

Hi @ValueRaider, first-timer here. I met the same issue today and saw your solution proposed. I'm curious about which line in the branch you mentioned to change.

ValueRaider commented 1 year ago

@KevinYew97 I've edited that post with a working link

KevinYew97 commented 1 year ago

Thanks! @ValueRaider. I have changed that particular code, but it's not working for me, both pdr_override and normal yf.download. I've tried with list of stocks and individual stocks, and no avail.

steven9909 commented 1 year ago

Surprised no one created a PR for this yet :(, created a PR here: https://github.com/ranaroussi/yfinance/pull/1488

JoanVendrellC commented 1 year ago

Do you have installed 'ta' library?

Because I had the same issue and I figured out that the error occurred when I installed that library. I have uninstalled it and it's working right now.

ValueRaider commented 1 year ago

@JoanVendrellC If ta interferes with latest release, create a new Issue

KingThutmose3 commented 1 year ago

still facing same issue over here, as others have mentioned, seems to only work during market hours

ValueRaider commented 1 year ago

@KingThutmose3 create a new Issue, follow the instructions

lguoca commented 1 year ago

autodata.py line771 , I fix this line as folllow, work fine

seconds=self._granularity_to_seconds(granularity, "yahoo") 1.5 count+86400

days=int((count*self._granularity_to_seconds(granularity, "yahoo"))/23400)+4

GreySnowFox commented 1 year ago

hi @ValueRaider you seem like the right man to help me!!! Please!

My error is the same repeating many times:

1 Failed download: ['---']: Exception('%ticker%: No timezone found, symbol may be delisted') No data available for ---. Skipping... [*100%***] 1 of 1 completed

I have now spent many many hours trying to work this out. I am really hoping you can help me. Here is part of my py script:

Imports

from pandas_datareader import data as pdr from yahoo_fin import stock_info as si from pandas import ExcelWriter import yfinance as yf import pandas as pd import datetime import time yf.pdr_override()

Variables

tickers = si.tickers_sp500() tickers = [item.replace(".", "-") for item in tickers] # Yahoo Finance uses dashes instead of dots index_name = '^GSPC' # S&P 500 start_date = datetime.datetime.now() - datetime.timedelta(days=365) exportList = pd.DataFrame(columns=['Stock', "RS_Rating", "50 Day MA", "150 Day Ma", "200 Day MA", "52 Week Low", "52 week High"]) returns_multiples = []

Index Returns

index_df = yf.download(index_name, start_date, end_date) index_df['Percent Change'] = index_df['Adj Close'].pct_change() index_return = (index_df['Percent Change'] + 1).cumprod()[-1]

Find top 30% performing stocks (relative to the S&P 500)

for ticker in tickers:

Download historical data as CSV for each stock (makes the process faster)

df = pdr.get_data_yahoo(ticker, start_date, end_date)

if df.empty:
    print(f"No data available for {ticker}. Skipping...")
    continue

df.to_csv(f'{ticker}.csv')

I tried adding the utcnow to the end of the datetime but still has an issue, i have been through all the other related issues that relate to this fix, but cant seem to resolve my specific one. I appreciate any assistance.

ValueRaider commented 1 year ago

Stop posting new issues in this thread, it's important to follow the new bug report instructions. Locking.