Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculatiing cumulative return

    Hello Everyone,

    I have daily stock returns data of 370 companies from the period 2000 to 2014. The data is in long form that contains firm ID, date and its respective return. I want to create 1 year momentum porfolio. For that, I want to calculate cumulative total return for the last one year excluding the last month (month t-12 to t-2) for each stock.
    I have collapsed the daily stock returns to months using the code

    Code:
    gen m_date = mofd(date)
    format m_date %tm
    collapse (sum) return, by( ID m_date year date)
    I am stuck at calculating comulative returns of 11 months exculding the last month

    Kindly suggest the code to compute the comulative returns and also let me know is a way to directly compute comulative returns through daily stock returns?

    Thank you

  • #2
    For monthly returns maybe it's not a big deal use the lag operator:

    Code:
    gen return_cumulated = return * return[_n-1]
    Then put it in a loop with temporary variables to cumulate it for all months. However, this is a bit awkward if you have daily data...

    Comment

    Working...
    X