0

I read on Internet and Stack Overflow different articles on Annual Return vs Annualised Return vs CAGR and I am a bit confused and I do not know if they are a different or same thing.

Here what I need. Suppose I have a growth rate of 10% over 3 years. Starting with 100$ I have:

Initial capital: 100$ Year 1: 110$ Year 2: 121$ Year 3: 133$

Now the Annual return here is 10% and Annual mean return should be 33/3=11%. Correct? Obviously, the Annual mean return does not give me a good measure of growth rate because does not take into account the compound interest. Am I correct?

Suppose now I reverse my input date in the problem. I have the initial capital 100$ and final 133$ and I want to calculate the growth rate. The formula should be (Capital final/Capital initial)^(1/3)-1.

(133/100)^(1/3)-1=(1,33)^(1/3)=0.098

that correspond more or less to 10%. Are my computation and reasoning correct so far? If so, what is the difference between Annual Return vs CAGR? It seems they are the same, correct?

Suppose now my time frame goes from September 10 2008 to Ferbuary 10 2012, my time frame is 3 years and 132 days. According to this website (see video) https://www.investopedia.com/ask/answers/071014/what-formula-calculating-compound-annual-growth-rate-cagr-excel.asp the number of years here is (3 + K) where K is the number of days converted in years, in our example K=132/365=0.36 so the number of years N=3+0.36=3.36 and this is the value I should use in the formula. Am I correct?

Now the last doubt is that the website to calculate K suggest to divide the number of days for 360 or 365 but should I consider in my calculation only the number of days the stock market is open (a number more or less equal to 272)?

The last question about python is, suppose I have a panda data frame df, can someone put a snippet of code I can use to calculate the Annual Return and/or CAGR. The code should take into consideration that the time frame could have a number of days more than one year and not perfectly a multiple of one year (like the example above).

I tried to write it but I am not sure I did a good job.

In addition, if my timeframe is less than one year what happens? Should I use Annualized Return? How the code change in this case?

Thanks in advance for help.

Salvatore D'angelo
  • 1,019
  • 3
  • 14
  • 39
  • 3
    I'm voting to close this question as off-topic because it is mostly about finance. And it is much too broad, containing multiple different questions. – Jean-François Corbett Jun 29 '18 at 06:42
  • My problem is that I have a python program where I am trying to estimate the performance of a single ETF. As you know before writing an algorithm you need to understand concepts first. I read lot of questions with theory before programming here. Why my case is different? As you notice I already did my research on theory first and I asked only for confirmation on few points. But my problem is that I am still unable to convert my understanding on code because I am a beginner programmer in python, especially on pandas. – Salvatore D'angelo Jun 29 '18 at 07:22

3 Answers3

3

Thanks to comments and some days of work I found detailed answers to my questions. I'll put them here for the benefits of others. I'll divide them in two parts: theory and programming.

Theory

According to my example above if I have an investment with 10% annual return and an initial capital of 100$ I have:

Year 1: 110$ Year 2: 121$ Year 3: 133.1$

The total earning is 33.1$ and it is called Cumulative Return. If you divide this earning for the number of years you get the Average mean return. It is a good estimation to understand trends but it does not take in consideration the compound interest. To get the real Annual Return you should apply this formula (that is derivative from Compound interest formula -- see Wikipedia for details).

Annual Return (or CAGR)=(Capital final/Capital initial)^(1/N)-1

Where N is the number of years. If the start date and end date of investment start on January 1st and finish on December 31th N is an integer, otherwise N could be a real number where the decimal part is calculated as 365/number of days.

Programming

Initially, since I am a beginner programmer in Python I thought to complex algorithms to calculate returns from my time series. Later, once I understand theory things became more easy. Suppose you have:

  • start_time
  • end_time
  • start_price
  • end_price

the cumulative return is an easy formula in python:

cum_return_percentage=((end_price/start_price) - 1)*100

also the annual return formula is easy to implement:

annual_return=(pow((end_price/start_price),(1/number_years))-1)*100

the problem is to calculate correctly the number_years as a real value that take into account the remaining days as decimal values. Here the code I am using:

diffyears=end_date.year - start_date.year
difference=end_date - start_date.replace(end_date.year)
days_in_year=isleap(end_date.year) and 366 or 365
number_years=diffyears + difference.days/days_in_year
annual_return=(pow((end_price/start_price),(1/number_years))-1)*100

To give the credits, this code comes from this discussion: Pythonic difference between two dates in years?

Hope this help other guys having my same problems.

Salvatore D'angelo
  • 1,019
  • 3
  • 14
  • 39
1

Your formulas are correct, but assuming 10% growth you end up at 133.1 NOT at 133.

Then: (133.1/100)^(1/3)-1 = 10%

freddy888
  • 956
  • 3
  • 18
  • 39
  • Thanks. Do you agree that CAGR is the same of Annual Return? While Annualised return refers to a return of a year extrapolated from a return got in a period of time less than one year? – Salvatore D'angelo Jun 29 '18 at 08:47
  • Obviously, there is no fixed term for annual return... but in this example I would say yes. – freddy888 Jun 29 '18 at 08:49
  • What about number of days to better calculate K and N in my formula? Should I assume a year of 365, 360 (I don't understand why the website video reports 360) or 272 (the number of days the stock market is open)? – Salvatore D'angelo Jun 29 '18 at 08:55
  • 360 is used for historical reasons when not everybody had a computer and dividing by 365 is difficult. Moreover, if you assume a month has 30 days its 30*12. https://en.wikipedia.org/wiki/Day_count_convention 272 makes no sense in this context. I would use 365 => 3.36 If you use 272 it would be to divide the actual trading days in your sample by 272. However, this should equal ~ 3.36 as well. – freddy888 Jun 29 '18 at 10:10
  • Thanks, I'll appreciate. The theory is clear now, but now I need info on Python the most important part. I am still trying to play with the data frame, list and tuple in order to calculate N in the formula. N=num years + days/365. The problem is to calculate exactly for each year the number of days. It's not easy for a python beginner like me. I found something on StackOverflow but it does not work. – Salvatore D'angelo Jun 29 '18 at 15:50
  • @FriedrichFranz for future reference, please avoid answering off-topic questions on this site. There is a finance StackExchange site, and this question belongs there rather than being encouraged here. – 0xdd Jul 10 '18 at 21:00
  • Feel free to deleted it if you think it is the right thing to do. My problem was a programming one. I am a programmer. But I needed to clarify theory first. Probably I could do that on site you suggested. I am sorry for this. Code was easier than expected once understand theory. – Salvatore D'angelo Jul 10 '18 at 21:45
  • I found this to compute exactly number of years https://stackoverflow.com/questions/4436957/pythonic-difference-between-two-dates-in-years that at the end was the hardest part to implement (I am not a Python expert and I have difficulties with dates) – Salvatore D'angelo Jul 10 '18 at 21:45
0
# We ask the user for the initial and final amounts of the investment

start_price = float(input('Initial investment amount: '))
end_price = float(input('Final amount of the investment: '))
start_time = input('Investment date: ')    
end_time = input('Final date considered for the CAGR calculation: ')
    
def CAGR(start_price, end_price, start_time, end_time):
    # days number
    fecha1 = datetime.strptime(start_time, "%Y-%m-%d")
    fecha2 = datetime.strptime(end_timeal, '%Y-%m-%d')
    dias = (fecha1 - fecha2).days
    años = dias/365
    return (end_price/start_price)**(1/años)-1
CAGR  = CAGR(start_price, end_price, start_time, end_time)

# CAGR is negative in the case of losses.
if start_price > end_price:
    CAGR = -CAGR
print ('Your investment had a CAGR of {:.2%} '.format(CAGR))
efueyo
  • 187
  • 1
  • 9