Convert table of Daily Stock data into Monthly data

조회 수: 3 (최근 30일)
Fabian Niederreiter
Fabian Niederreiter 2021년 3월 12일
편집: Cris LaPierre 2021년 3월 20일
I have a 13000x3000 table with colums representing the dates and rows representing the stocks with values of daily stock returns in it.
Now I'd like to get the monthly sum of returns for each stock (each line).
Would appreciate any kind of help.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 12일
Look into groupsummary.
Use the date info as your groupvar.
Use the appropriate value for your groupbin (sounds like you want 'monthly').
Specify the desired method (sounds like you want 'sum')
  댓글 수: 6
Cris LaPierre
Cris LaPierre 2021년 3월 15일
편집: Cris LaPierre 2021년 3월 20일
It would appear that your grouping variable, dates, is not valid with the syntax you are using.
When you use the table form, your grouping variable needs to be a variable in the table. Try adding dates as a new column in your table rather than as the rownames.
G_CRSP.dates = dates;
Then your groupsummary statement should work.
Fabian Niederreiter
Fabian Niederreiter 2021년 3월 20일
Thanks for your help Chris! With some adjustments to my data I managed to make it work with the help of groupsummary. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by