Tag Archives: data management

  • 0

Find annual | monthly cumulative (product) of returns

Category:Blog Tags : 

The problem

Let’s say that we have daily stock returns. We want to convert those returns to cumulative returns for a weekly, monthly or yearly frequency.

Where cumulative returns = (1+Ri1) * (1+Ri2) * (1+R3) * … (1+R4) – 1



First create the weekly, monthly or year identifier, and then use asrol program.

Let us use this data set [Click here to download], also shown below and find returns for different frequencies.

input id str20 D returns
 1 30jun1993 .7437958 
 1 02jul1993 .0674011 
 1 06jul1993 .2668857 
 1 14jul1993 .0454151 
 1 19jul1993 .1340756 
 1 29jul1993 .8053644 
 1 13aug1993 .5861199 
 1 24sep1993 .3200437 
 1 19oct1993 .0098762 
 1 19oct1993 .005197 
g date = date(D, "DMY")
drop D


Find weekly cumulative returns

Let us first install asrol from ssc

ssc install asrol

Now create weekly date

gen week = wofd(date)

Now find the returns using asrol

bys id week :  asrol returns, stat(product) add(1)

Note : add(1) adds 1 with each returns before multiplication and then subtracts 1 at the end.

Find monthly cumulative returns

gen month = mofd(date)
bys id month:  asrol returns, stat(product) add(1)

Find yearly cumulative returns

 gen year= year(date)
bys id year:  asrol returns, stat(product) add(1)