We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
yf.Ticker.history
yf.download
The yf.Ticker.history function returns "adjusted close" data labelled as "Close" values for tickers.
The yf.download function provides "Close" and "Adj Close" values separately.
This is confusing because I would expect the "Close" price to have the same meaning regardless of which API function I am using.
import pandas as pd import yfinance as yf yf.enable_debug_mode() ticker = "ALX" start_date, end_date = "2019-01-01", "2024-11-01" stock = yf.Ticker(ticker) share_price_download = yf.download(ticker, start_date, end_date) share_price_download.index = share_price_download.index.tz_localize(None) share_price_download_close = share_price_download["Close"][ticker] share_price_download_adj_close = share_price_download["Adj Close"][ticker] share_price_yf_history = stock.history(start=start_date, end=end_date) share_price_yf_history.index = share_price_yf_history.index.tz_localize(None) share_price_yf_history_close = share_price_yf_history.Close pd.merge( pd.DataFrame(share_price_download_close.rename("close - yf.download")), pd.DataFrame(share_price_yf_history_close.rename("close - yf.Ticker.history")), left_index=True, right_index=True, ).plot(title=ticker) pd.merge( pd.DataFrame(share_price_download_close.rename("close - yf.download")), pd.DataFrame(share_price_download_adj_close.rename("adj close - yf.download")), left_index=True, right_index=True, ).plot(title=ticker)
DEBUG Entering download() DEBUG Disabling multithreading because DEBUG logging enabled DEBUG Entering history() DEBUG Entering history() DEBUG ALX: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00-05:00', 'period2': '2024-11-01 00:00:00-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG ALX: yfinance received OHLC data: 2019-01-02 14:30:00 -> 2024-10-31 13:30:00 DEBUG ALX: OHLC after cleaning: 2019-01-02 09:30:00-05:00 -> 2024-10-31 09:30:00-04:00 DEBUG ALX: OHLC after combining events: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00 DEBUG ALX: yfinance returning OHLC: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00 DEBUG Exiting history() DEBUG Exiting history() DEBUG Exiting download() DEBUG Entering history() DEBUG Entering history() DEBUG ALX: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00-05:00', 'period2': '2024-11-01 00:00:00-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG ALX: yfinance received OHLC data: 2019-01-02 14:30:00 -> 2024-10-31 13:30:00 DEBUG ALX: OHLC after cleaning: 2019-01-02 09:30:00-05:00 -> 2024-10-31 09:30:00-04:00 DEBUG ALX: OHLC after combining events: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00 DEBUG ALX: yfinance returning OHLC: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00 DEBUG Exiting history() DEBUG Exiting history()
yfinance
0.2.50
Python 3.11.1
Ubuntu 22.04
The text was updated successfully, but these errors were encountered:
Duplicate of #1999, but that was closed when you posted so I'll leave this open.
You're 100% right. It should be auto_adjust=True imo, stop naive algo-trading triggering on ex-div drops. #1084
auto_adjust=True
Sorry, something went wrong.
imo this is now fixed with auto_adjust being defaulted to True in 0.2.51 for download.
No branches or pull requests
Describe bug
The
yf.Ticker.history
function returns "adjusted close" data labelled as "Close" values for tickers.The
yf.download
function provides "Close" and "Adj Close" values separately.This is confusing because I would expect the "Close" price to have the same meaning regardless of which API function I am using.
Simple code that reproduces your problem
Debug log
DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG ALX: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00-05:00', 'period2': '2024-11-01 00:00:00-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG ALX: yfinance received OHLC data: 2019-01-02 14:30:00 -> 2024-10-31 13:30:00
DEBUG ALX: OHLC after cleaning: 2019-01-02 09:30:00-05:00 -> 2024-10-31 09:30:00-04:00
DEBUG ALX: OHLC after combining events: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00
DEBUG ALX: yfinance returning OHLC: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Exiting download()
DEBUG Entering history()
DEBUG Entering history()
DEBUG ALX: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00-05:00', 'period2': '2024-11-01 00:00:00-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG ALX: yfinance received OHLC data: 2019-01-02 14:30:00 -> 2024-10-31 13:30:00
DEBUG ALX: OHLC after cleaning: 2019-01-02 09:30:00-05:00 -> 2024-10-31 09:30:00-04:00
DEBUG ALX: OHLC after combining events: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00
DEBUG ALX: yfinance returning OHLC: 2019-01-02 00:00:00-05:00 -> 2024-10-31 00:00:00-04:00
DEBUG Exiting history()
DEBUG Exiting history()
Bad data proof
yfinance
version0.2.50
Python version
Python 3.11.1
Operating system
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: