yfinance: Adjusted Close from yfinance is not the same as total return from Yahoo Finance

I am trying to calculate the monthly and annual percent return for a fund like VSMPX. My understanding is that the Adjusted Close from yfinance takes into account splits and dividends.

To get the percent return I am doing:

  hist = ticker.history(start="2020-01-01", end=None, interval="1d", auto_adjust=True)
  # Calculate daily, monthly, and annual percentage returns
  daily_returns = hist['Close'].pct_change()
  monthly_returns = hist['Close'].resample('M').last().pct_change()
  annual_returns = hist['Close'].resample('Y').last().pct_change()
  
  # Save the returns to CSV files
  daily_returns.to_csv("VSMPX_daily_adjusted_returns.csv")
  monthly_returns.to_csv("VSMPX_monthly_adjusted_returns.csv")
  annual_returns.to_csv("VSMPX_annual_adjusted_returns.csv")

My annual return is the following:

2016-12-31 00:00:00-05:00,0.12694628348918013
2017-12-31 00:00:00-05:00,0.21189241900874567
2018-12-31 00:00:00-05:00,-0.05155696029590995
2019-12-31 00:00:00-05:00,0.3079293379439798
2020-12-31 00:00:00-05:00,0.21010764518963132
2021-12-31 00:00:00-05:00,0.2574150697504418
2022-12-31 00:00:00-05:00,-0.19501641528697433
2023-12-31 00:00:00-05:00,0.26013908084513204

However, when I check the total return percentage on the Yahoo Finance website, my adjusted return percentages are off by a little. image

For example, you can see that my 2019 annual return is 30.79%, but on Yahoo Finance, it is 30.82%. I realize this is a small descripency but I want 1) Understand why there is a difference 2) I noticed every other total return is the same as Yahoo Finance, so concerned I am doing something wrong.

About this issue

Most upvoted comments

I think the confusion is from the way that Yahoo calculates “Adj Close.” See: https://quant.stackexchange.com/questions/42445/total-returns-from-adjusted-close-prices https://help.yahoo.com/kb/SLN28256.html Regular “Close” price is what you want because it still takes into account splits. The “Adj Close” is going to reduce the close price whenever there is a dividend distribution. The non-DRIP calculation comes out correct if you use: hist = stock_data.history(start=start_date, end=end_date, interval='1d', auto_adjust=False, actions=True) And then add the dividends back in as @jharemza said with: total_return = ((final_price + total_dividends) / initial_price) - 1 You can test the output with an online calculator Any minor differences are just rounding errors.

@deeleeramone @ValueRaider Thanks for the answer! Although, I am not quite sure if I follow. Would it be possible to post a code snippet to calculate total return using yfinance?