Dear All
I need some help with the stock returns. I would like to calculate weekly stock returns from the daily returns data. However, I need the value only for those weeks in which the stock was traded and have data for. For instance, following is the daily returns data:
input long StockCode float(YEAR month day) double dailyreturn
1 2005 1 4 -.010622
1 2005 1 5 -.009202
1 2005 1 6 .009288
1 2005 1 7 -.001534
1 2005 1 10 .012289
1 2005 1 12 -.009105
1 2005 1 13 .006126
1 2005 1 14 -.010654
1 2005 1 17 -.038462
1 2005 1 18 -.0048
1 2005 1 19 -.009646
1 2005 1 20 -.024351
1 2005 1 21 .066556
1 2005 1 24 .00936
1 2005 1 25 -.02473
1 2005 1 26 -.001585
1 2005 1 27 -.025397
1 2005 1 28 .004886
1 2005 1 31 -.017828
1 2005 2 1 .00495
1 2005 2 2 .050903
1 2005 2 3 -.014063
1 2005 2 4 .045959
1 2005 2 16 -.001515
1 2005 2 17 -.004552
1 2005 2 18 .006098
1 2005 2 21 .016667
1 2005 2 22 .004471
1 2005 2 23 -.010386
1 2005 2 24 -.005997
1 2005 2 25 .001508
1 2005 2 28 -.024096
end
The format I require is below:
input byte StockCode str7 TradingWeek double return
1 "2005-09" .006061
1 "2005-08" 0
1 "2005-06" .069692
1 "2005-05" -.037441
1 "2005-04" -.013846
1 "2005-03" -.001536
1 "2005-02" -.01214
end
Would highly appreciate if I can get some help with the above command.
Regards
Yahya
I need some help with the stock returns. I would like to calculate weekly stock returns from the daily returns data. However, I need the value only for those weeks in which the stock was traded and have data for. For instance, following is the daily returns data:
input long StockCode float(YEAR month day) double dailyreturn
1 2005 1 4 -.010622
1 2005 1 5 -.009202
1 2005 1 6 .009288
1 2005 1 7 -.001534
1 2005 1 10 .012289
1 2005 1 12 -.009105
1 2005 1 13 .006126
1 2005 1 14 -.010654
1 2005 1 17 -.038462
1 2005 1 18 -.0048
1 2005 1 19 -.009646
1 2005 1 20 -.024351
1 2005 1 21 .066556
1 2005 1 24 .00936
1 2005 1 25 -.02473
1 2005 1 26 -.001585
1 2005 1 27 -.025397
1 2005 1 28 .004886
1 2005 1 31 -.017828
1 2005 2 1 .00495
1 2005 2 2 .050903
1 2005 2 3 -.014063
1 2005 2 4 .045959
1 2005 2 16 -.001515
1 2005 2 17 -.004552
1 2005 2 18 .006098
1 2005 2 21 .016667
1 2005 2 22 .004471
1 2005 2 23 -.010386
1 2005 2 24 -.005997
1 2005 2 25 .001508
1 2005 2 28 -.024096
end
The format I require is below:
input byte StockCode str7 TradingWeek double return
1 "2005-09" .006061
1 "2005-08" 0
1 "2005-06" .069692
1 "2005-05" -.037441
1 "2005-04" -.013846
1 "2005-03" -.001536
1 "2005-02" -.01214
end
Would highly appreciate if I can get some help with the above command.
Regards
Yahya
Comment