yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

API not returning current day's data

Open FallakAsad opened this issue 3 years ago • 3 comments

Running the following code to get the historical data, but the current day i.e 1.Nov.2021 is not getting included in the returned list. Even though the market is open. It was not like this few days ago, the current day was always included.

import yfinance as yf

tickers = yf.Tickers('aapl')
print(tickers.tickers)
print(tickers.tickers['
AAPL'].history(period="1mo"))

Open High Low Close Volume Dividends Stock Splits Date 2021-10-01 141.899994 142.919998 139.110001 142.649994 94639600 0 0 2021-10-04 141.759995 142.210007 138.270004 139.139999 98322000 0 0 2021-10-05 139.490005 142.240005 139.360001 141.110001 80861100 0 0 2021-10-06 139.470001 142.149994 138.369995 142.000000 83221100 0 0 2021-10-07 143.059998 144.220001 142.720001 143.289993 61732700 0 0 2021-10-08 144.029999 144.179993 142.559998 142.899994 58718700 0 0 2021-10-11 142.270004 144.809998 141.809998 142.809998 64452200 0 0 2021-10-12 143.229996 143.250000 141.039993 141.509995 73035900 0 0 2021-10-13 141.240005 141.399994 139.199997 140.910004 78762700 0 0 2021-10-14 142.110001 143.880005 141.509995 143.759995 69907100 0 0 2021-10-15 143.770004 144.899994 143.509995 144.839996 67885200 0 0 2021-10-18 143.449997 146.839996 143.160004 146.550003 85589200 0 0 2021-10-19 147.009995 149.169998 146.550003 148.759995 76378900 0 0 2021-10-20 148.699997 149.750000 148.119995 149.259995 58418800 0 0 2021-10-21 148.809998 149.639999 147.869995 149.479996 61421000 0 0 2021-10-22 149.690002 150.179993 148.639999 148.690002 58839600 0 0 2021-10-25 148.679993 149.369995 147.619995 148.639999 50720600 0 0 2021-10-26 149.330002 150.839996 149.009995 149.320007 60893400 0 0 2021-10-27 149.360001 149.729996 148.490005 148.850006 56094900 0 0 2021-10-28 149.820007 153.169998 149.720001 152.570007 100077900 0 0 2021-10-29 147.220001 149.940002 146.410004 149.800003 124850400 0 0

FallakAsad avatar Nov 01 '21 18:11 FallakAsad

Yeah, similar problem with the "regularMarketPrice" key from the Ticker().info dictionaries. Oftentimes they value returned is None. previousClose also often returns a wrong value.

PNeigel avatar Nov 02 '21 11:11 PNeigel

Yeah, similar problem with the "regularMarketPrice" key from the Ticker().info dictionaries. Oftentimes they value returned is None. previousClose also often returns a wrong value.

This can happen. It is the responsibility of the yfinance user (i.e. the caller of Ticker()) To verify the data by cehcking on the provided values You can see many such exmples here: https://github.com/asafravid/sss

asafravid avatar Nov 02 '21 12:11 asafravid

This could be a timezone bug. I'm testing a timezone fix that might fix your issue: https://github.com/ValueRaider/yfinance/tree/fix/timezone

You'll have to play with sys.path.insert to load this over PIP. Give it a play, let me know if it fixes.

ValueRaider avatar Jun 16 '22 19:06 ValueRaider