如何使用R将数据转换为时间序列?

时间:2016-11-23 13:07:39

标签: r time-series portfolio quantitative-finance

我有一个股票相关报价的日内数据集。如何将其转换为时间序列?

            Time    Size Ask    Bid    Trade
11-1-2016   9:00:12 100 <NA>    901     <NA>
11-1-2016   9:00:21 5   <NA>    <NA>    950
11-1-2016   9:00:21 5   <NA>    950     <NA>
11-1-2016   9:00:21 10  905     <NA>    <NA>
11-1-2016   9:00:24 500 <NA>    921     <NA>
11-1-2016   9:00:28 2   <NA>    879     <NA>
11-1-2016   9:00:31 6   1040    <NA>    <NA>
11-1-2016   9:00:39 5   <NA>    <NA>    950
11-1-2016   9:00:39 5   <NA>    950     <NA>
11-1-2016   9:00:39 10  905     <NA>    <NA>
11-1-2016   9:00:39 5   <NA>    <NA>    950
11-1-2016   9:00:44 2   <NA>    879     <NA>
11-1-2016   9:00:44 6   1040    <NA>    <NA>
11-1-2016   9:00:45 1   1005    <NA>    <NA>
11-1-2016   9:00:46 1   1000    <NA>    <NA>
11-1-2016   9:00:47 1   <NA>    900     <NA>
11-1-2016   9:00:47 5   <NA>    <NA>    950
11-1-2016   9:00:47 5   <NA>    950     <NA>
11-1-2016   9:00:47 10  905     <NA>    <NA>
11-1-2016   9:00:48 1   <NA>    900     <NA>
11-1-2016   9:00:48 1   1000    <NA>    <NA>
11-1-2016   9:00:52 5   <NA>    <NA>    950
11-1-2016   9:00:52 5   <NA>    950     <NA>
11-1-2016   9:00:52 10  905     <NA>    <NA>
11-1-2016   9:00:53 10  <NA>    <NA>    939
11-1-2016   9:00:55 1   <NA>    900     <NA>
11-1-2016   9:00:55 1   1000    <NA>    <NA>
11-1-2016   9:00:55 10  <NA>    <NA>    939
11-1-2016   9:00:55 5   <NA>    950     <NA>
11-1-2016   9:00:55 10  905     <NA>    <NA>
11-1-2016   9:00:59 10  <NA>    <NA>    939
11-1-2016   9:01:04 10  <NA>    <NA>    950
11-1-2016   9:01:04 25  <NA>    950     <NA>
11-1-2016   9:01:06 1   <NA>    900     <NA>
11-1-2016   9:01:06 1   1000    <NA>    <NA>
11-1-2016   9:01:14 19  <NA>    <NA>    972
11-1-2016   9:01:14 20  <NA>    972     <NA>
11-1-2016   9:01:14 10  905     <NA>    <NA>
11-1-2016   9:01:17 19  <NA>    <NA>    972
11-1-2016   9:01:17 1   <NA>    912     <NA>

数据集的结构是

'data.frame':   35797 obs. of  5 variables:
 $ Time : POSIXct, format: "2016-11-01 09:00:12" "2016-11-01 09:00:21" ..
 $ Size : chr  "100" "5" "5" "10" ...
 $ ASk  : chr  NA NA NA "905" ...
 $ Bid  : chr  "901" NA "950" NA ...
 $ Trade: chr  NA "950" NA NA ...

将数据转换为时间序列对象后,如何每5分钟汇总一次询价,买入和交易列。

0 个答案:

没有答案