我正在使用交易记录数据库,调查市场微观结构。以下示例代码适用于特定交易日。
建议使用什么方法来确定xts对象索引的日期,然后用它来遍历下面的代码,每天?
my.xts <- xts(my.frame1[,-1], order.by=my.frame1[,1])
my.val <- my.xts[,1]*my.xts[,2]
my.cumvol <- cumsum(my.xts[,2])
my.cumval <- cumsum(my.val[,1])
my.vwap <- my.cumval/my.cumvol
my.ratio <- (my.xts[,1]/my.vwap - 1)*10000
op <- par(mfrow=c(1,2))
plot(my.ratio)
plot(my.xts[,1])
lines(my.vwap)
par(op)
my.xts示例:
PRICE QUANTITY
2013-06-05 10:00:08 2772 1250
2013-06-05 10:00:08 2772 1204
2013-06-05 10:00:11 2772 1773
2013-06-05 10:00:11 2772 62
2013-06-05 10:00:11 2773 1250
2013-06-05 10:00:11 2773 1250
2013-06-05 10:00:14 2773 1250
2013-06-05 10:00:14 2773 1250
2013-06-05 10:00:14 2772 1217
2013-06-05 10:00:33 2773 1811
2013-06-05 10:00:33 2773 1250
2013-06-05 10:00:42 2773 1610
2013-06-05 10:00:42 2773 1420
2013-06-05 10:00:42 2773 190
2013-06-05 10:01:17 2773 1357
2013-06-05 10:01:17 2773 1800
2013-06-05 10:01:17 2773 1495
2013-06-05 10:01:17 2773 283
2013-06-05 10:02:07 2775 246
2013-06-05 10:02:07 2775 171
2013-06-05 10:02:07 2775 1233
2013-06-05 10:02:14 2775 1500
2013-06-05 10:02:33 2773 700
2013-06-05 10:02:40 2773 3034
2013-06-05 10:02:40 2773 750
2013-06-05 10:02:40 2773 1498
2013-06-05 10:02:58 2773 515
2013-06-05 10:02:58 2773 11985
2013-06-05 10:03:02 2773 1665
2013-06-05 10:03:03 2772 1360
2013-06-05 10:03:03 2771 1140
2013-06-05 10:03:08 2775 3325
2013-06-05 10:03:34 2772 1500
2013-06-05 10:03:34 2772 1360
2013-06-05 10:03:34 2772 1220
2013-06-05 10:03:34 2772 3323
2013-06-05 10:03:42 2772 327
2013-06-05 10:04:13 2775 3339
2013-06-05 10:04:39 2773 7730
2013-06-05 10:04:48 2775 1554
2013-06-05 10:05:15 2774 3561
2013-06-05 10:05:15 2774 1439
2013-06-05 10:05:16 2773 577
2013-06-05 10:05:16 2773 2225
2013-06-05 10:05:16 2773 1083
2013-06-05 10:05:16 2773 1900
2013-06-05 10:05:16 2774 1502
2013-06-05 10:05:16 2773 102
2013-06-05 10:05:16 2773 1338
2013-06-05 10:05:16 2773 1228
2013-06-05 10:05:16 2773 2270
2013-06-05 10:05:26 2773 2775
2013-06-05 10:05:36 2772 9000
2013-06-05 10:05:36 2772 1000
2013-06-05 10:05:42 2773 2409
2013-06-05 10:05:44 2773 464
2013-06-05 10:05:44 2773 1743
2013-06-05 10:05:44 2773 1477
2013-06-05 10:05:44 2773 1925
2013-06-05 10:05:44 2773 2438
2013-06-05 10:05:44 2773 309
2013-06-05 10:05:44 2773 1932
2013-06-05 10:05:44 2773 1447
2013-06-05 10:05:44 2773 446
2013-06-05 10:05:44 2773 1410
2013-06-05 10:05:44 2773 372
2013-06-05 10:05:44 2773 715
2013-06-05 10:05:44 2773 847
2013-06-05 10:05:44 2773 1628
2013-06-05 10:05:44 2773 1574
2013-06-05 10:05:44 2773 1504
2013-06-05 10:05:44 2773 963
2013-06-05 10:05:44 2773 1531
2013-06-05 10:05:44 2773 1628
2013-06-05 10:05:44 2773 2185
2013-06-05 10:05:44 2773 1639
2013-06-05 10:05:44 2773 2330
2013-06-05 10:05:44 2773 2113
2013-06-05 10:05:44 2773 841
2013-06-05 10:05:45 2773 2226
2013-06-05 10:05:45 2773 1332
2013-06-05 10:05:45 2773 2320
2013-06-05 10:05:45 2773 845
2013-06-05 10:05:45 2773 1665
2013-06-05 10:05:45 2773 609
2013-06-05 10:05:45 2773 2226
2013-06-05 10:05:45 2773 1497
2013-06-05 10:05:45 2773 405
2013-06-05 10:05:45 2773 1022
2013-06-05 10:05:45 2773 174
2013-06-05 10:05:45 2773 1608
2013-06-05 10:05:45 2773 228
2013-06-05 10:05:45 2773 2020
2013-06-05 10:05:45 2773 1885
2013-06-05 10:05:45 2773 1524
2013-06-05 10:05:45 2773 2262
2013-06-05 10:05:45 2773 1618
2013-06-05 10:05:45 2773 2060
2013-06-05 10:05:45 2773 1843
2013-06-05 10:05:45 2773 2036
2013-06-05 10:05:45 2773 293
2013-06-05 10:05:45 2773 2034
2013-06-05 10:05:45 2773 1039
2013-06-05 10:05:45 2773 704
2013-06-05 10:05:46 2773 91
2013-06-05 10:05:46 2773 1135
2013-06-05 10:05:46 2773 1583
2013-06-05 10:05:46 2773 972
2013-06-05 10:05:46 2773 1309
2013-06-05 10:05:46 2773 2429
2013-06-05 10:05:46 2773 2164
2013-06-05 10:05:46 2773 1708
2013-06-05 10:05:46 2773 1527
2013-06-05 10:05:46 2773 2174
2013-06-05 10:05:46 2773 434
2013-06-05 10:05:46 2773 892
2013-06-05 10:05:46 2773 1554
2013-06-05 10:05:46 2773 2091
2013-06-05 10:05:46 2773 2107
2013-06-05 10:05:46 2773 1933
2013-06-05 10:05:46 2773 2341
2013-06-05 10:05:46 2773 619
2013-06-05 10:05:46 2773 623
2013-06-05 10:05:46 2773 2393
2013-06-05 10:05:46 2773 1977
2013-06-05 10:05:46 2773 1897
2013-06-05 10:05:46 2773 204
2013-06-05 10:05:46 2773 890
2013-06-05 10:05:46 2773 1738
2013-06-05 10:05:46 2773 1998
2013-06-05 10:05:46 2773 1684
2013-06-05 10:05:46 2773 1069
2013-06-05 10:05:46 2773 1578
2013-06-05 10:05:46 2773 1769
2013-06-05 10:05:47 2773 1535
2013-06-05 10:05:47 2773 1159
2013-06-05 10:05:47 2773 1354
2013-06-05 10:05:47 2773 1300
2013-06-05 10:05:47 2773 1300
2013-06-05 10:05:47 2773 1605
2013-06-05 10:05:47 2773 937
2013-06-05 10:05:47 2775 2802
2013-06-05 10:05:47 2773 2063
2013-06-05 10:05:47 2773 2095
2013-06-05 10:05:47 2773 283
2013-06-05 10:05:47 2773 366
2013-06-05 10:05:47 2773 1940
2013-06-05 10:05:52 2775 2011
2013-06-05 10:05:52 2775 1135
2013-06-05 10:06:01 2775 3184
2013-06-05 10:06:02 2775 3184
2013-06-05 10:06:02 2775 1911
2013-06-05 10:06:02 2775 3184
2013-06-05 10:06:02 2775 3184
2013-06-05 10:06:05 2779 703
2013-06-05 10:06:05 2779 1109
2013-06-05 10:06:05 2779 2802
2013-06-05 10:06:05 2779 1212
2013-06-05 10:06:05 2778 740
2013-06-05 10:06:05 2777 1346
2013-06-05 10:06:05 2778 260
2013-06-05 10:06:06 2779 1591
2013-06-05 10:06:06 2780 51
2013-06-05 10:06:07 2779 3006
2013-06-05 10:06:18 2779 3188
2013-06-05 10:06:18 2779 3188
2013-06-05 10:06:18 2779 564
2013-06-05 10:06:18 2779 2624
2013-06-05 10:06:19 2779 2207
2013-06-05 10:06:21 2776 1136
2013-06-05 10:06:21 2776 1300
2013-06-05 10:06:21 2776 1300
2013-06-05 10:06:21 2776 1800
2013-06-05 10:06:21 2776 16
2013-06-05 10:06:30 2780 3051
2013-06-05 10:06:30 2780 3179
2013-06-05 10:06:30 2779 229
2013-06-05 10:06:30 2780 2950
2013-06-05 10:06:41 2780 3171
2013-06-05 10:06:41 2780 2598
2013-06-05 10:06:41 2780 573
2013-06-05 10:06:41 2780 859
2013-06-05 10:06:49 2780 4768
2013-06-05 10:06:49 2780 2338
2013-06-05 10:06:49 2780 2856
2013-06-05 10:06:49 2780 38
2013-06-05 10:06:52 2782 292
2013-06-05 10:06:52 2781 2932
2013-06-05 10:07:34 2782 209
2013-06-05 10:07:34 2782 3255
2013-06-05 10:07:42 2780 1435
2013-06-05 10:07:42 2780 1285
2013-06-05 10:07:42 2780 400
2013-06-05 10:07:42 2780 637
2013-06-05 10:07:42 2780 1547
2013-06-05 10:07:42 2780 263
2013-06-05 10:07:42 2780 5200
2013-06-05 10:07:42 2780 5200
2013-06-05 10:07:42 2782 4475
2013-06-05 10:07:42 2780 2663
2013-06-05 10:07:42 2780 438
2013-06-05 10:07:42 2780 5200
2013-06-05 10:07:42 2781 1900
2013-06-05 10:07:42 2780 510
2013-06-05 10:07:42 2780 910
2013-06-05 10:07:42 2782 2646
2013-06-05 10:07:42 2780 1445
2013-06-05 10:07:42 2780 4290
2013-06-05 10:07:42 2780 3477
2013-06-05 10:07:42 2780 4800
2013-06-05 10:07:43 2780 3200
2013-06-05 10:07:43 2780 3877
2013-06-05 10:07:43 2780 1323
2013-06-05 10:07:54 2782 2373
2013-06-05 10:07:59 2782 3249
2013-06-05 10:08:03 2780 2077
2013-06-05 10:08:03 2780 10000
2013-06-05 10:08:03 2780 1903
2013-06-05 10:08:03 2780 1226
2013-06-05 10:08:03 2780 670
2013-06-05 10:08:03 2780 7359
2013-06-05 10:08:03 2780 2923
2013-06-05 10:08:03 2780 10000
2013-06-05 10:08:03 2780 564
2013-06-05 10:08:04 2780 1488
2013-06-05 10:08:11 2780 200
2013-06-05 10:08:11 2780 223
2013-06-05 10:08:11 2780 4713
2013-06-05 10:08:13 2778 1453
2013-06-05 10:08:13 2780 1500
2013-06-05 10:08:13 2780 1594
2013-06-05 10:08:13 2780 8837
2013-06-05 10:08:13 2780 1599
2013-06-05 10:08:13 2780 3186
2013-06-05 10:08:13 2780 10000
2013-06-05 10:08:13 2780 10000
2013-06-05 10:08:13 2780 2763
2013-06-05 10:08:13 2780 1163
2013-06-05 10:08:13 2780 1900
2013-06-05 10:08:14 2782 2924
2013-06-05 10:08:23 2782 3183
2013-06-05 10:08:24 2782 1572
2013-06-05 10:08:24 2780 1211
2013-06-05 10:08:24 2782 1372
2013-06-05 10:08:24 2782 239
2013-06-05 10:08:24 2782 2581
2013-06-05 10:08:24 2782 3183
2013-06-05 10:08:25 2780 5596
2013-06-05 10:08:25 2780 1845
2013-06-05 10:08:25 2780 1307
2013-06-05 10:08:25 2780 1500
2013-06-05 10:08:25 2780 6604
2013-06-05 10:08:25 2780 10000
2013-06-05 10:08:25 2780 1300
2013-06-05 10:08:37 2782 597
2013-06-05 10:08:37 2782 3180
2013-06-05 10:08:39 2780 2028
2013-06-05 10:08:39 2780 3005
2013-06-05 10:08:39 2780 251
2013-06-05 10:08:39 2780 1430
2013-06-05 10:08:39 2780 244
2013-06-05 10:08:39 2780 673
2013-06-05 10:08:39 2781 1300
2013-06-05 10:08:39 2780 1500
2013-06-05 10:08:39 2780 10000
2013-06-05 10:08:39 2780 947
2013-06-05 10:08:39 2781 1500
2013-06-05 10:08:39 2780 10000
2013-06-05 10:08:42 2782 886
2013-06-05 10:08:46 2782 717
2013-06-05 10:08:46 2784 283
2013-06-05 10:08:50 2780 1889
2013-06-05 10:08:50 2780 2254
2013-06-05 10:08:50 2780 1650
2013-06-05 10:08:50 2780 1300
2013-06-05 10:08:50 2780 1549
2013-06-05 10:08:50 2780 1758
2013-06-05 10:08:50 2780 2274
2013-06-05 10:08:50 2780 1097
2013-06-05 10:08:50 2780 1500
2013-06-05 10:08:51 2780 1804
2013-06-05 10:08:51 2780 2386
2013-06-05 10:08:51 2780 2337
2013-06-05 10:08:51 2780 2042
2013-06-05 10:08:51 2780 2377
2013-06-05 10:08:51 2780 2066
2013-06-05 10:08:51 2780 182
2013-06-05 10:08:51 2780 1784
2013-06-05 10:08:51 2780 1913
2013-06-05 10:08:51 2780 457
2013-06-05 10:08:51 2780 2429
2013-06-05 10:08:51 2780 1511
2013-06-05 10:08:51 2780 2316
2013-06-05 10:08:51 2780 1569
2013-06-05 10:08:51 2780 2008
2013-06-05 10:08:51 2780 777
2013-06-05 10:08:51 2780 1792
2013-06-05 10:08:51 2780 1815
2013-06-05 10:08:51 2780 933
2013-06-05 10:08:51 2780 1684
2013-06-05 10:08:51 2780 2255
2013-06-05 10:08:51 2780 2049
2013-06-05 10:08:51 2780 1858
2013-06-05 10:08:51 2780 1659
2013-06-05 10:08:56 2784 1000
2013-06-05 10:08:56 2784 3717
2013-06-05 10:08:57 2783 3173
2013-06-05 10:08:57 2783 3173
2013-06-05 10:08:57 2783 3173
2013-06-05 10:08:58 2783 1215
2013-06-05 10:08:58 2783 3173
2013-06-05 10:09:09 2780 2469
2013-06-05 10:09:09 2780 2412
2013-06-05 10:09:09 2780 1859
2013-06-05 10:09:09 2780 3186
2013-06-05 10:09:09 2780 1732
2013-06-05 10:09:09 2780 1787
2013-06-05 10:09:09 2780 1827
2013-06-05 10:09:09 2780 2419
2013-06-05 10:09:09 2780 2238
2013-06-05 10:09:09 2780 2120
2013-06-05 10:09:09 2780 1300
2013-06-05 10:09:09 2780 3186
2013-06-05 10:09:10 2780 1846
2013-06-05 10:09:10 2780 1023
2013-06-05 10:09:10 2780 2213
2013-06-05 10:09:10 2780 1514
2013-06-05 10:09:10 2780 2172
2013-06-05 10:09:10 2780 1741
2013-06-05 10:09:10 2780 2267
2013-06-05 10:09:10 2780 1523
2013-06-05 10:09:10 2780 1510
2013-06-05 10:09:10 2780 2056
2013-06-05 10:09:10 2780 1593
2013-06-05 10:09:10 2780 3186
2013-06-05 10:09:10 2780 1727
2013-06-05 10:09:10 2780 276
2013-06-05 10:09:10 2780 771
2013-06-05 10:09:10 2780 2240
2013-06-05 10:09:10 2780 2134
2013-06-05 10:09:19 2783 3174
2013-06-05 10:09:20 2783 3174
2013-06-05 10:09:20 2783 1207
2013-06-05 10:09:20 2783 3174
2013-06-05 10:09:20 2783 3174
2013-06-05 10:09:21 2780 2238
2013-06-05 10:09:21 2780 1619
2013-06-05 10:09:21 2780 938
2013-06-05 10:09:21 2780 1572
2013-06-05 10:09:21 2780 2496
2013-06-05 10:09:21 2780 2339
2013-06-05 10:09:21 2780 2457
2013-06-05 10:09:21 2780 2398
2013-06-05 10:09:21 2780 1806
2013-06-05 10:09:21 2780 1811
2013-06-05 10:09:21 2780 1300
2013-06-05 10:09:21 2780 1907
2013-06-05 10:09:21 2780 1804
2013-06-05 10:09:21 2780 1919
2013-06-05 10:09:21 2780 2098
2013-06-05 10:09:22 2780 808
2013-06-05 10:09:22 2780 2128
2013-06-05 10:09:22 2780 1604
2013-06-05 10:09:22 2780 1620
2013-06-05 10:09:22 2778 303
2013-06-05 10:09:22 2778 1362
2013-06-05 10:09:22 2780 1910
2013-06-05 10:09:22 2780 2277
2013-06-05 10:09:22 2778 1331
2013-06-05 10:09:22 2780 2018
2013-06-05 10:09:22 2780 2422
2013-06-05 10:09:22 2780 2142
2013-06-05 10:09:22 2778 341
2013-06-05 10:09:22 2780 142
2013-06-05 10:09:22 2780 2222
2013-06-05 10:09:22 2780 1502
2013-06-05 10:09:22 2780 2271
2013-06-05 10:09:22 2780 1574
2013-06-05 10:09:22 2780 2187
2013-06-05 10:09:22 2780 1515
2013-06-05 10:09:22 2780 2079
2013-06-05 10:09:22 2780 1669
2013-06-05 10:09:23 2778 1115
2013-06-05 10:09:23 2780 1857
2013-06-05 10:09:23 2777 1750
2013-06-05 10:09:23 2777 1650
2013-06-05 10:09:35 2783 1010
2013-06-05 10:09:35 2783 2190
2013-06-05 10:09:35 2783 3200
2013-06-05 10:09:35 2783 3200
2013-06-05 10:09:35 2783 3200
2013-06-05 10:09:36 2783 796
2013-06-05 10:09:49 2783 3191
2013-06-05 10:09:49 2783 3117
2013-06-05 10:09:49 2783 1926
2013-06-05 10:09:49 2783 74
2013-06-05 10:10:01 2783 1512
2013-06-05 10:10:01 2783 2687
2013-06-05 10:10:16 2783 3145
2013-06-05 10:10:16 2783 966
2013-06-05 10:10:27 2783 662
2013-06-06 10:00:40 2733 353
2013-06-06 10:00:40 2733 2145
2013-06-06 10:00:40 2733 1569
2013-06-06 10:00:58 2732 9000
2013-06-06 10:00:58 2732 1500
2013-06-06 10:00:58 2732 1884
2013-06-06 10:00:58 2732 2508
2013-06-06 10:01:00 2732 5942
2013-06-06 10:01:03 2732 650
2013-06-06 10:01:03 2732 250
2013-06-06 10:01:03 2732 1458
2013-06-06 10:01:04 2732 712
2013-06-06 10:01:04 2732 1674
2013-06-06 10:01:04 2732 26
2013-06-06 10:01:08 2732 901
2013-06-06 10:01:21 2732 1386
2013-06-06 10:01:21 2732 422
2013-06-06 10:01:22 2732 1600
2013-06-06 10:01:34 2731 3003
2013-06-06 10:01:34 2731 1361
2013-06-06 10:01:34 2731 3000
2013-06-06 10:01:34 2731 1541
2013-06-06 10:01:34 2731 4000
2013-06-06 10:01:35 2730 4723
2013-06-06 10:01:38 2732 1000
2013-06-06 10:01:41 2732 5758
2013-06-06 10:01:41 2732 1932
2013-06-06 10:01:41 2732 8092
2013-06-06 10:01:41 2732 9253
2013-06-06 10:01:41 2732 2549
2013-06-06 10:01:41 2732 704
2013-06-06 10:01:41 2732 6654
2013-06-06 10:01:55 2735 500
2013-06-06 10:02:01 2733 1260
2013-06-06 10:02:01 2733 1260
2013-06-06 10:02:01 2733 1997
2013-06-06 10:02:01 2733 419
2013-06-06 10:03:13 2735 1813
2013-06-06 10:03:16 2735 1832
2013-06-06 10:03:16 2735 374
2013-06-06 10:03:16 2735 2864
2013-06-06 10:03:16 2735 4324
2013-06-06 10:03:17 2735 2245
2013-06-06 10:03:18 2735 5645
2013-06-06 10:03:18 2735 2518
2013-06-06 10:03:19 2735 1305
2013-06-06 10:03:19 2735 1354
2013-06-06 10:03:21 2735 597
2013-06-06 10:03:21 2735 1712
2013-06-06 10:03:22 2735 200
2013-06-06 10:03:22 2735 197
2013-06-06 10:03:22 2735 2045
2013-06-06 10:03:22 2735 45
2013-06-06 10:03:25 2737 200
2013-06-06 10:03:29 2735 2234
2013-06-06 10:03:34 2739 1500
2013-06-06 10:03:41 2739 4458
2013-06-06 10:03:41 2739 2500
2013-06-06 10:03:46 2739 14603
2013-06-06 10:03:50 2736 359
2013-06-06 10:04:06 2739 1088
2013-06-06 10:04:10 2739 1499
2013-06-06 10:04:10 2739 1
2013-06-06 10:04:11 2739 1
2013-06-06 10:04:11 2739 1495
2013-06-06 10:04:16 2739 3505
2013-06-06 10:04:19 2740 172
2013-06-06 10:04:19 2738 9910
2013-06-06 10:04:19 2738 1300
2013-06-06 10:04:24 2738 1468
2013-06-06 10:04:24 2738 1824
2013-06-06 10:04:41 2739 1601
2013-06-06 10:04:47 2738 4595
2013-06-06 10:04:53 2738 394
2013-06-06 10:04:53 2738 6165
2013-06-06 10:04:53 2738 6162
2013-06-06 10:04:53 2738 1800
2013-06-06 10:04:53 2738 5479
2013-06-06 10:05:01 2739 7985
2013-06-06 10:05:05 2739 1947
2013-06-06 10:05:08 2740 5000
2013-06-06 10:05:08 2739 3664
2013-06-06 10:05:08 2739 5527
2013-06-06 10:05:08 2740 3056
2013-06-06 10:05:08 2740 5000
2013-06-06 10:05:53 2740 516
2013-06-06 10:06:07 2740 1000
2013-06-06 10:06:44 2740 3347
2013-06-06 10:06:44 2740 3653
2013-06-06 10:06:58 2740 730
2013-06-06 10:07:27 2738 4613
2013-06-06 10:07:27 2738 1532
2013-06-06 10:07:27 2738 1505
2013-06-06 10:07:38 2738 100
2013-06-06 10:07:47 2738 6052
2013-06-06 10:07:47 2738 5287
2013-06-06 10:07:47 2738 1542
2013-06-06 10:07:47 2738 1443
2013-06-06 10:08:17 2739 5419
2013-06-06 10:08:17 2739 3650
2013-06-06 10:08:17 2739 3385
2013-06-06 10:08:17 2739 2149
2013-06-06 10:08:19 2738 1936
2013-06-06 10:08:22 2738 3971
2013-06-06 10:08:29 2739 1961
2013-06-06 10:08:29 2739 4278
2013-06-06 10:08:29 2739 1426
2013-06-06 10:08:32 2739 1847
2013-06-06 10:08:38 2739 3838
2013-06-06 10:08:38 2740 2662
2013-06-06 10:08:44 2740 1963
2013-06-06 10:08:45 2740 300
2013-06-06 10:08:52 2740 75
2013-06-06 10:08:52 2740 75
2013-06-06 10:08:52 2740 75
2013-06-06 10:08:52 2740 75
2013-06-06 10:08:52 2740 31
2013-06-06 10:09:12 2745 3210
2013-06-06 10:09:12 2745 3381
2013-06-06 10:09:12 2745 1331
2013-06-06 10:09:12 2745 69
2013-06-06 10:09:12 2745 3649
2013-06-06 10:09:12 2745 3000
2013-06-06 10:09:12 2745 5912
2013-06-06 10:09:12 2745 1487
2013-06-06 10:09:28 2745 5000
2013-06-06 10:09:28 2745 5000
2013-06-06 10:09:56 2745 1829
2013-06-06 10:09:57 2745 1918
2013-06-06 10:09:57 2745 1082
2013-06-06 10:10:05 2745 3000
2013-06-06 10:10:05 2745 1724
2013-06-06 10:10:05 2746 2467
2013-06-06 10:10:05 2745 3000
2013-06-06 10:10:05 2745 2911
2013-06-06 10:10:06 2745 1000
2013-06-06 10:10:06 2745 3000
2013-06-06 10:10:06 2745 2911
2013-06-06 10:10:07 2745 2911
2013-06-06 10:10:07 2745 2911
2013-06-06 10:10:08 2745 2911
2013-06-06 10:10:08 2745 2911
2013-06-06 10:10:09 2745 2911
2013-06-06 10:10:10 2745 2911
2013-06-06 10:10:10 2745 2911
2013-06-06 10:10:11 2745 2911
2013-06-06 10:10:12 2745 2911
2013-06-06 10:10:13 2745 2911
2013-06-06 10:10:13 2748 1877
2013-06-06 10:10:14 2745 2911
2013-06-06 10:10:17 2745 1777
2013-06-06 10:10:42 2746 1430
2013-06-06 10:10:42 2745 1134
2013-06-06 10:10:43 2746 1430
2013-06-06 10:10:44 2745 1553
2013-06-06 10:10:44 2745 1430
2013-06-06 10:10:44 2745 1282
2013-06-06 10:10:44 2745 8866
2013-06-06 10:10:45 2745 1926
答案 0 :(得分:1)
希望这有效......
full.xts.obj
是您使用my.frame1
转换为xts对象的所有数据创建的xts对象
your.code.func <- function(my.xts){
my.val <- my.xts[,1]*my.xts[,2]
my.cumvol <- cumsum(my.xts[,2])
my.cumval <- cumsum(my.val[,1])
my.vwap <- my.cumval/my.cumvol
my.ratio <- (my.xts[,1]/my.vwap - 1)*10000
op <- par(mfrow=c(1,2))
plot(my.ratio)
plot(my.xts[,1])
lines(my.vwap)
par(op)
}
data.list <- split(full.xts.obj,'days')
for(i in c(1:(length(data.list))){
tmp <- data.list[[i]]
your.code.func(tmp)
}