Splitting up data vector into matrix with weekly data separated by columns
이전 댓글 표시
Greetings,
I have a Dataset containing 1-minute Stock Returns for a Period of 6 months. I have a Table containing the Date in the first column, and then the closing Prices in the next column. In total that equals roughly 187000 closing prices. The 6-month Period starts at 2008.09.01 00:00:00, and ends 2009.03.01.00:00:00.
Since i want to do weekly regressions, i now have to convert the vector of the closing Prices into a Matrix, where the first column contains all the closing prices for the first Week, the second column contains all the closing prices of the second week and so on.
However, weekends are excluded in the dataset, and not every week has the same amount of closing prices, since at some point time shift from Summer to Winter time has to be considered, which is why i cannot simply divide the data into equal parts. The last closing price of the week is always 20:59:00 (Summer Time) or 21:59:00 (Winter Time) on each Friday. Quotes then continue in the next week on Sunday 21:00:00 (Summer Time) or 22:00:00 (Winter Time).
Therefore I either need a loop, which writes me a new matrix from the vector until the condition: write data in first column until the last closing price of the week has arrived, then stop, proceed to next column and then continue writing the next datapoint in the next column until the last closing price of week 2 has arrived and so on,
Or maybe if there is some way to do this without a loop just using the find function to show me where exactly in the dataset every new week starts, however, i haven't been able to do that.
Thanks in Advance!

댓글 수: 1
dpb
2019년 7월 22일
Be far easier to have at least a portion of the actual file...are the weekend dates included in the file or only trading times for one question.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!