yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

the latest date OLHC data appears NaN during dividend and trading hours

Open anarchy89 opened this issue 3 years ago • 2 comments

so I ran this command,

yf.Ticker('ALB').history(period='1d')

its supposed to look like this

This is from yahoo finance at the time, during trading hours.

Date Open High Low Close* Adj Close** Volume
Mar 17, 2022 187.84 196.09 187.84 195.21 195.21 403,080
Mar 17, 2022 0.395 Dividend
Mar 16, 2022 185.87 193.98 185.76 191.25 190.85 890,700
Mar 15, 2022 175.36 182.70 172.78 181.95 181.57 834,400

But this is what I got.

Date Open High Low Close Volume Dividends Stock Splits
2022-03-17 NaN NaN NaN NaN NaN 0.395 0

It only showed me the latest empty dividend data, not the prices above it. even if I run this

yf.Ticker('ALB').history(),

the latest date shows me only the blank dividend data when it should be showing me

Date Open High Low Close* Adj Close** Volume
Mar 17, 2022 187.84 196.09 187.84 195.21 195.21 403,080

according to the yahoo finance data

this seems to happen because there was a dividend today for this stock, on the yahoo finance website it shows

Date Open High Low Close* Adj Close** Volume
Mar 17, 2022 187.84 196.09 187.84 195.21 195.21 403,080
Mar 17, 2022 0.395 Dividend
Mar 16, 2022 185.87 193.98 185.76 191.25 190.85 890,700
Mar 15, 2022 175.36 182.70 172.78 181.95 181.57 834,400

but in the Python API, it only shows up till the dividend split and gives me Nans in the other columns

if I use pandas data reader,

import pandas_datareader as pdr pdr.get_data_yahoo('ALB')

I get the proper data like this,

  High Low Open Close Volume Adj Close

106.190002 | 105.120003 | 106.040001 | 106.070000 | 1032400.0 | 98.987755 107.559998 | 104.070000 | 106.070000 | 104.250000 | 1249500.0 | 97.289299 105.470001 | 103.300003 | 104.599998 | 105.220001 | 984800.0 | 98.194519 106.389999 | 104.849998 | 105.180000 | 105.150002 | 690000.0 | 98.129196 106.180000 | 104.029999 | 105.540001 | 104.449997 | 527400.0 | 97.475929 ... | ... | ... | ... | ... | ... 191.449997 | 184.639999 | 188.770004 | 184.759995 | 769600.0 | 184.378403 186.169998 | 175.259995 | 184.869995 | 176.289993 | 973200.0 | 175.925888 182.699997 | 172.779999 | 175.360001 | 181.949997 | 834400.0 | 181.574203 193.979996 | 185.759995 | 185.869995 | 191.250000 | 890700.0 | 190.854996 196.360001 | 187.839996 | 187.839996 | 196.205002 | 487406.0 | 196.205002

anarchy89 avatar Mar 17 '22 19:03 anarchy89

It is currently happening again with the ticker WPM and PM today.

anarchy89 avatar Mar 23 '22 13:03 anarchy89

I have also observed, suffered, from this feature. It seems to have started when I updated to the latest version of yfinance.

Oneingrate avatar Mar 26 '22 00:03 Oneingrate

I have pushed out a fix to version 0.2.0rc1 (on PIP). I would greatly appreciate feedback. You can always downgrade to 0.1 if problems.

ValueRaider avatar Oct 27 '22 22:10 ValueRaider