Hello everyone,
I have daily panel data with prices and returns for several companies.
My question is, how do I calculate Buy and Hold returns for every company and every day in the sample.
E.g. 1-year holding period returns for ARCHER-DANIELS-MIDLAND on 15th March 2020 (until 14th March 2021), 16th March 2020 (until 15th March 2021), ...
Please keep in mind that in the data only trading days are included.
I have looked for a solution for several hours but haven't found anything that exactly matches my problem. I think using asrol and generating an identifying variable could work out. Indeed for the first day of the year and a yearly variable this works out, however, already for the second trading day of the year, one observation is missing. In addition, I thought about generating an identifying dummy variable for every date, however, this is probably not the best solution, since my dataset is really large (c. 15 million observations).
Best regards,
Jakob Stoll
I have daily panel data with prices and returns for several companies.
My question is, how do I calculate Buy and Hold returns for every company and every day in the sample.
E.g. 1-year holding period returns for ARCHER-DANIELS-MIDLAND on 15th March 2020 (until 14th March 2021), 16th March 2020 (until 15th March 2021), ...
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERMNO str58 CONM long caldt double prccd float RETURN 10516 "ARCHER-DANIELS-MIDLAND CO" 17136 34.83 . 10516 "ARCHER-DANIELS-MIDLAND CO" 17139 34.85 .0005741212 10516 "ARCHER-DANIELS-MIDLAND CO" 17140 34.58 -.007747393 10516 "ARCHER-DANIELS-MIDLAND CO" 17141 34.3 -.008097241 10516 "ARCHER-DANIELS-MIDLAND CO" 17142 33.76 -.015743468 10516 "ARCHER-DANIELS-MIDLAND CO" 17143 34.07 .009182505 10516 "ARCHER-DANIELS-MIDLAND CO" 17146 33.69 -.01115354 10516 "ARCHER-DANIELS-MIDLAND CO" 17147 33.47 -.006530051 10516 "ARCHER-DANIELS-MIDLAND CO" 17148 32.76 -.02121311 10516 "ARCHER-DANIELS-MIDLAND CO" 17149 32.62 -.004273486 10516 "ARCHER-DANIELS-MIDLAND CO" 17150 32.72 .003065674 10516 "ARCHER-DANIELS-MIDLAND CO" 17153 32.06 -.020171143 end format %td caldt
I have looked for a solution for several hours but haven't found anything that exactly matches my problem. I think using asrol and generating an identifying variable could work out. Indeed for the first day of the year and a yearly variable this works out, however, already for the second trading day of the year, one observation is missing. In addition, I thought about generating an identifying dummy variable for every date, however, this is probably not the best solution, since my dataset is really large (c. 15 million observations).
Code:
gen fyear1 = year(caldt) bysort PERMNO fyear1 : asrol RETURN, stat(product) add(1)
Jakob Stoll
Comment