简体   繁体   中英

Time series Matrix multiplication for portfolio return calculation using R

I have a high frequency trading dataset of 10 stocks between 11:00 am to 11:30 am, which I have aggregated to 30 sec interval. Subsequently I have calculated the return of these 10 stocks.

How to I perform matrix multiplication of the below time series return dataset with another weight matrix, where the weight matrix is a (10 x 1) matrix and each row value is 0.1

Snippet of the Return series 

                             Return        Return.1         Return.2       Return.3       Return.4          Return.5         Return.6   Return.7       Return.8       Return.9
2016-11-01  11:01:00    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000    0.0000000000
2016-11-01  11:01:30    0.0000000000    -0.0000114972   0.0000000000    0.0017831901    0.0000000000    0.0000000000    -0.0000436291   0.0000000000    -0.0004361599   0.0006955877
2016-11-01  11:02:00    0.0000000000    0.0001367691    0.0000000000    -0.0013306210   0.2858388000    0.0000000000    0.0000895993    0.0073684211    -0.0001821495   0.0000115851
2016-11-01  11:02:30    0.0000000000    0.0007165496    0.0032948929    0.0001158209    0.0000000000    0.0000896138    -0.0001382266   0.0000000000    -0.0001045696   0.0000000000

The data can be downloaded from the link

https://www.dropbox.com/s/dwvsl11j7t1884b/Time%20Series%20Return%20data.xlsx?dl=0

I think what you need is basic matrix multiplication, which can be done in R using %*%.

For example:

a=matrix(1:6,2,3)
b=matrix(10:21,3,4)
a%*%b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM