In this short guide, we will learn how to handle the yfinance auto_adjust parameter change and understand what auto_adjust=True actually does to your stock price data. This breaking change in yfinance 0.2.28+ now automatically adjusts historical prices for dividends and splits, which can break existing code expecting unadjusted prices.
Example warning message from yfinnance:
YF.download() has changed argument auto_adjust default to True
Problem: Breaking Change in yfinance
The yf.download() function changed its default auto_adjust parameter from False to True, causing existing scripts to return adjusted prices instead of raw prices, breaking technical analysis, backtesting, and price calculations.
What auto_adjust=True Does
When auto_adjust=True, yfinance:
- Removes the "Adj Close" column
- Adjusts Open, High, Low, Close for splits and dividends
- Adjusts Volume inversely for stock splits
- Returns split-adjusted and dividend-adjusted historical prices
import yfinance as yf
apple = yf.download('AAPL', start='2024-01-01', end='2024-02-01', auto_adjust=True)
print("With auto_adjust=True (NEW DEFAULT):")
print(apple[['Open', 'Close', 'Volume']].head())
print(f"Columns: {list(apple.columns)}")
Output Result:
With auto_adjust=True (NEW DEFAULT):
Open Close Volume
Date
2024-01-02 187.15000 185.639999 82488800
2024-01-03 184.220001 184.250000 58414800
2024-01-04 182.149994 181.910004 81152300
2024-01-05 181.990005 181.179993 80962700
2024-01-08 181.300003 185.559998 98297300
Columns: ['Open', 'High', 'Low', 'Close', 'Volume']
Solution: Control Price Adjustment Behavior
1. Get Unadjusted Prices (Old Behavior)
Set auto_adjust=False to get raw, unadjusted prices with the Adj Close column included.
import yfinance as yf
microsoft = yf.download('MSFT', start='2024-01-01', end='2024-02-01', auto_adjust=False)
print("With auto_adjust=False (OLD DEFAULT):")
print(microsoft[['Close', 'Adj Close', 'Volume']].head())
print(f"\nDifference: Close - Adj Close = {(microsoft['Close'] - microsoft['Adj Close']).head()}")
Output Result:
With auto_adjust=False (OLD DEFAULT):
Close Adj Close Volume
Date
2024-01-02 374.579987 372.549286 27842000
2024-01-03 368.049988 366.051849 28832100
2024-01-04 368.899994 366.896271 23169600
2024-01-05 369.540009 367.532806 24042400
2024-01-08 370.369995 368.357849 23334200
Difference: Close - Adj Close =
Date
2024-01-02 2.030701
2024-01-03 1.998139
2024-01-04 2.003723
2024-01-05 2.007183
2024-01-08 2.012146
2. Migration Strategy for Existing Code
Fix legacy code by explicitly setting auto_adjust=False to maintain backward compatibility.
import yfinance as yf
def get_stock_data_legacy(ticker, start, end):
return yf.download(ticker, start=start, end=end, auto_adjust=False, progress=False)
tesla = get_stock_data_legacy('TSLA', '2024-01-01', '2024-01-10')
print(f"Columns available: {list(tesla.columns)}")
print(f"Has Adj Close: {'Adj Close' in tesla.columns}")
Output Result:
Columns available: ['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']
Has Adj Close: True
Common Use Cases
Backtesting: Use auto_adjust=True for accurate historical total returns
Price Charts: Use auto_adjust=False to show actual traded prices
Technical Analysis: Depends on strategy - RSI/MACD work with either
Dividend Analysis: Use auto_adjust=False to see ex-dividend price drops
Quick Reference
| Parameter | Adj Close Column | Prices Adjusted | Use Case |
|---|---|---|---|
| auto_adjust=True | No | Yes | Backtesting, returns |
| auto_adjust=False | Yes | No | Price charts, raw data |