yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Close/Adj Close in yf.Ticker vs yf.download

Open mlettau opened this issue 3 years ago • 5 comments

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.

mlettau avatar Oct 22 '21 19:10 mlettau

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.

ValueRaider avatar Jan 06 '23 21:01 ValueRaider

What does community think?

ValueRaider avatar Jan 06 '23 21:01 ValueRaider

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 avatar Jan 07 '23 09:01 galashour

@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).

ValueRaider avatar Jan 07 '23 16:01 ValueRaider

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.

ValueRaider avatar Jan 13 '23 14:01 ValueRaider