I'm calculate annualized return for intraday strategy but it not give me correct output

I'm calculate annualized return for intraday strategy but it not give me correct output



this formula works in days strategy​​​​​​​ 

# Calculate compounded annual growth rate
def get_CAGR(df):
    days = len(df)
    return "{0:.2f}%".format((df['returns'].iloc[-1]**(252/days)-1)*100)

1) data length is 39000 row

2) time frame = 10 min 

3) total year = 4 years



Please correct  my formula code for intraday strategy

Hey Shirish,



The code that you have shared is more or less perfect, just one tiny error. It seems that you have set "days" as the length of your minute-wise dataframe. So what's happening here is that you are dividing 252 days by minutes. Try dividing it by the number of days to get the correct output.



Since you have 39000 rows of 10 mins data, the number of days would be approximately 1000.



Here's how I got the number of days:

6 10-minute rows = 1 hour

6.5 trading hours = 1 day



6 (10-minute rows) * 6.5 (trading hours) = 39



Convert the number of minute-wise rows into days:

39000 (number of rows) / 39 = 1000 days



Hope you find this helpful.



Thanks,

Rushda Ansari