Including Dividends in Year-to-Date Investment Returns
Summary
The discussion explains how to include cash dividends when calculating an asset’s year-to-date return for performance analysis or backtesting. If dividends are not reinvested, the suggested calculation adds dividends received during the period to the ending price, then compares that total with the starting price. This captures the cash income alongside the price change.
A second answer points to a Python workflow that obtains historical prices and computes price-return and total-return series, then compounds and compares them. The example uses market data and illustrates how rankings can differ when dividends are included. The package described is explicitly presented as experimental, and the excerpt does not detail its dividend data handling or reinvestment conventions. Results therefore depend on the chosen return definition, accurate dividend records, and consistent period endpoints; the simple cash-addition formula assumes dividends are not reinvested.
Key ideas
- A return calculation that excludes dividends measures price performance rather than total return.
- For dividends held as cash, add distributions received during the period to the ending asset price before comparing with the starting price.
- A total-return series can be compounded to compare cumulative performance with price returns.
- Backtests depend on dividend data quality and on whether the method assumes distributions are reinvested.
Tags
Full text
# how to calculate YTD return including the paid dividends
# how to calculate YTD return including the paid dividends
I am looking for a way to compute YTD return and I found this question (calculate YTD return / find first available datapoint of a year in python), however, it seems that it does not include the paid dividend in the year. How can I compute YTD return including the paid dividends?
My goal is to add this into my Python code for more accurate backtesting, so I would appreciate it if your answer considers Python implementation.
## Answer by oronimbus (score 2)
https://quant.stackexchange.com/a/76287
I've recently created a Python package called pyTAA as a side hobby to analyse low-frequency strategies. This is very much in alpha and can change at any point in time. To answer your question, I've added some tools to do precisely what you're asking. You can find the implementation here, all that is needed is `yfinance` really.
And a small code snippit to compare price vs total returns:
```
from pytaa.backtest.returns import get_historical_total_return
from pytaa.tools.data import get_historical_price_data
start, end = "2013-01-01", "2023-05-01"
assets = ["SPY", "AGG", "IEF", "GLD", "EEM"]
prices = get_historical_price_data(assets, start, end).loc[:, "Close"]
total_returns = get_historical_total_return(prices, "USD", "total")
price_returns = get_historical_total_return(prices, "USD", "price")
# plot price returns
cpr = price_returns.add(1).cumprod()
cpr.plot(figsize=(8,5), title="Cumulative Price Returns")
print(cpr.tail(1).rank(axis=1, ascending=False))
# plot total returns
ctr = total_returns.add(1).cumprod()
ctr.plot(figsize=(8,5), title="Cumulative Total Returns")
ctr.tail(1).rank(axis=1, ascending=False)
# show the last period cum returns
comp = pd.concat([
cpr.tail(1).rename({cpr.index[-1]: "Price Return"}),
ctr.tail(1).rename({ctr.index[-1]: "Total Return"})
])
comp.index.name = ""
comp.mul(100).round(2)
```
## Answer by D Stanley (score 1)
https://quant.stackexchange.com/a/68233
Assuming you aren't reinvesting the dividend in the stock, your YTD return would just be the price on date `n`plus the dividends received up to that date divided by the initial price:
```
ytd_return = (price_n + div_ytd) / price_0
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.