Course Name: Technical Indicators Strategies in Python, Section No: 6, Unit No: 6, Unit type: Notebook
Can you please elaborate more on how "n" is calculated in the CAGR?
Course Name: Technical Indicators Strategies in Python, Section No: 6, Unit No: 6, Unit type: Notebook
Can you please elaborate more on how "n" is calculated in the CAGR?
Hi Amit,
# Total number of trading candles per day
n = data.loc[datetime.datetime.strftime(data.index[-1].date(),'%Y-%m-%d')].shape[0]
# Total number of trading candles over time
trading_candles = len(data['Cumulative_Returns'])
# Calculate compound annual growth rate
performance_metrics['CAGR'] = "{0:.2f}%".format((data.Cumulative_Returns.iloc[-1]**(252*n/trading_candles)-1)*100)
thank you very much Kevin.