The cumulative return of an investment is the aggregate return that an investment has gained or lost over time (it can be both positive or negative). If you have Open-High-Low-Close stock data, you can compute cumulative returns on its adjusted price as dividends, and stock splits will lead to incorrect results.

$R_c = \frac{P_c}{P_i} - 1$

where $$R_c$$ is the cumulative return, $$P_c$$ is the current price, and $$P_i$$ is the initial price. If a stock’s price was 20 dollars on January 1st, 2015, and 67 dollars on January 1st, 2018, then the cumulative return is 235%.

cumulative_return <- function(latest_price, first_price) {
ret <- (latest_price / first_price) - 1
return(ret)
}

cumulative_return(67, 20) * 100
## [1] 235

Annualized returns are useful when you want to compare the performances of securities that have been on the market for different amounts of time. Unless a stock has traded less than a year, you can compute the annualized return as

$R_a = (1 + R_c) ^ \frac{1}{n} - 1$

where $$n$$ is the number of years over which the cumulative return took place. With our previous example, it turns out that the annual rate of return for our security is 11%.

annualized_returns <- function(cumulative, years) {
ret <- ((1 + cumulative)**1/years) - 1
return(ret)
}

annualized_returns(2.35, 3) * 100
## [1] 11.66667