ranaroussi / yfinance

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

Unable to get history of ASIANPAINT.NS on May 4, 2022 #2044

Open tapadeep opened 2 months ago

tapadeep commented 2 months ago

Describe bug

My previously working script has started to throw the following error:

ERROR:yfinance:Could not get exchangeTimezoneName for ticker 'ASIANPAINT.NS' reason: 'chart' ERROR:yfinance:$ASIANPAINT.NS: possibly delisted; no timezone found

Simple code that reproduces your problem


import yfinance as yf
import datetime as datetime0
from datetime import datetime
yf.enable_debug_mode()
yf.__version__
stock=yf.Ticker('ASIANPAINT.NS')
date=datetime.strptime('4-May-22','%d-%b-%y').date()
details=stock.history(start=date,end=date+datetime0.timedelta(days=1))

### Debug log

> DEBUG    Entering history()
DEBUG:yfinance:Entering history()
DEBUG     Entering _fetch_ticker_tz()
DEBUG:yfinance: Entering _fetch_ticker_tz()
ERROR      Could not get exchangeTimezoneName for ticker 'ASIANPAINT.NS' reason: 'chart'
ERROR:yfinance:  Could not get exchangeTimezoneName for ticker 'ASIANPAINT.NS' reason: 'chart'
DEBUG      Got response: 
DEBUG:yfinance:  Got response: 
DEBUG      -------------
DEBUG:yfinance:  -------------
DEBUG       {'finance': {'result': None, 'error': {'code': 'Internal Server Error', 'description': 'Duplicate key 1497411900'}}}
DEBUG:yfinance:   {'finance': {'result': None, 'error': {'code': 'Internal Server Error', 'description': 'Duplicate key 1497411900'}}}
DEBUG      -------------
DEBUG:yfinance:  -------------
DEBUG     Exiting _fetch_ticker_tz()
DEBUG:yfinance: Exiting _fetch_ticker_tz()
DEBUG     Entering history()
DEBUG:yfinance: Entering history()
ERROR      $ASIANPAINT.NS: possibly delisted; no timezone found
ERROR:yfinance:  $ASIANPAINT.NS: possibly delisted; no timezone found
DEBUG     Exiting history()
DEBUG:yfinance: Exiting history()
DEBUG    Exiting history()
DEBUG:yfinance:Exiting history()

### Bad data proof

![baddata_proof](https://github.com/user-attachments/assets/e7aec73d-ca58-4f16-beff-d2d0202addd8)

### `yfinance` version

0.2.43

### Python version

3.10.12

### Operating system

Ubuntu v22.04
ValueRaider commented 2 months ago

Your bad data proof must be from yahoo.com

tapadeep commented 1 month ago

Your bad data proof must be from yahoo.com Oops, here you go.. yf_asianpaints

ValueRaider commented 1 month ago

Looking closer, May 4 is irrelevant.

DEBUG:yfinance: Entering _fetch_ticker_tz()
ERROR      Could not get exchangeTimezoneName for ticker 'ASIANPAINT.NS' reason: 'chart'

_fetch_ticker_tz is failing but only for you. Can you experiment with its code? Maybe the date range is too short. It's in base.py

divyankm commented 1 month ago

Today I get the same error, till yesterday it worked for same Symbol, Error, Python, Yfinance version is same.

https://github.com/ranaroussi/yfinance/issues/2052