yfinance
yfinance copied to clipboard
Close/Adj Close in yf.Ticker vs yf.download
yf.download returns a df with columns ['Open', 'High', 'Low', 'Close', 'Volume', 'Dividends', 'Stock Splits'] while the columns of yf.Ticker().history are ['Open', 'High', 'Low', 'Close', 'Volume', 'Dividends', 'Stock Splits']. The 'Close' columns in yf.Ticker().history is actually the 'Adj Close' columns in yf.Ticker().history, which can lead to confusion.
I think it would be preferable to change the column name 'Close' to 'Adj Close' in yf.Ticker().history, or include 'Close' and 'Adj Close' in the returned dataframe.
Indeed this creates a lot of confusion. But an argument against change is it would break all users codes that isn't disabling dividend-adjustment.
What does community think?
hmm.. I can see why this could cause some pain, but longerterm we may want to have consistency. BTW, some libraries return both 'close' and 'adjclose', so that users can choose which they want. Depending on the nature of the change made, possibly a warning message could be added (in the next 1-2 releases) to raise awareness.
p.s. Not sure if other libraries like yahooquery and pandas-datareader use yfinance or parse their data directly (and if they use yfinance, which method they use download/history).
@galashour Good point. So 2 stages: pre-warning message, then future implementation.
Regarding returning both close
and adj close
: already possible if user disables adjustment: auto_adjust=False
. Btw returning both is maybe bad idea for weekly & monthly because Yahoo's adjustment is broken (see #1273 for details).
I've changed my mind on renaming columns because it will break a lot of user code. Better to resolve through documentation, whether in README or Wiki.