0

我有带有 OHLC 和 DateTime 数据的 CSV,数据是用 1 分钟的条形图采样的,我想计算不同时间范围的 VWAP。如何索引框架以获取特定日期内的所有时间?

let csv_temp = Frame.ReadCsv<DateTime>(filepath, indexCol ="Date and Time")

然后

(csv_temp?Close * csv_temp?Volume)

这给了我:

1/2/2013 9:31:00 AM  -> 65088       
1/2/2013 9:32:00 AM  -> 4432997.7   
1/2/2013 9:33:00 AM  -> 1407412.375 
1/2/2013 9:34:00 AM  -> 918077      
1/2/2013 9:35:00 AM  -> 1037200.32  
1/2/2013 9:36:00 AM  -> 1464104.6   
1/2/2013 9:37:00 AM  -> 1179067.16  
1/2/2013 9:38:00 AM  -> 1416311.45  
1/2/2013 9:39:00 AM  -> 1893821.16  
1/2/2013 9:40:00 AM  -> 521449.4442 
1/2/2013 9:41:00 AM  -> 656896.779  
1/2/2013 9:42:00 AM  -> 518200.425  
1/2/2013 9:43:00 AM  -> 1327152.28  
1/2/2013 9:44:00 AM  -> 1035047.64  
1/2/2013 9:45:00 AM  -> 1133165.55  
...                  -> ...         
4/10/2015 3:46:00 PM -> 1284412.341 
4/10/2015 3:47:00 PM -> 900809.43   
4/10/2015 3:48:00 PM -> 542263.54   
4/10/2015 3:49:00 PM -> 393960.84   
4/10/2015 3:50:00 PM -> 1395440.96  
4/10/2015 3:51:00 PM -> 1927824.3   
4/10/2015 3:52:00 PM -> 1458494.1   
4/10/2015 3:53:00 PM -> 1092189.57  
4/10/2015 3:54:00 PM -> 1675165.38  
4/10/2015 3:55:00 PM -> 987443.275  
4/10/2015 3:56:00 PM -> 1519896.625 
4/10/2015 3:57:00 PM -> 1100833.68  
4/10/2015 3:58:00 PM -> 1216154.3   
4/10/2015 3:59:00 PM -> 1648792.64  
4/10/2015 4:00:00 PM -> 5523283.36

我想要类似的东西:

(csv_temp?Close * csv_temp?Volume).GetRowsWith(DateTime(2013,1,2))

然后将不同时间跨度的数据分块来计算平均值?

这可能吗?

谢谢!

4

2 回答 2

0

我无权访问您正在使用的 CSV 文件,所以我没有尝试过。但是你应该能够做类似的事情(filtered?Close * filtered?Volume) |> Series.groupInto (fun k _ -> k.Date) (fun _ group -> Stats.mean group)

这将计算close*volume每分钟的时间,然后按Date- 部分(即按天)对它们进行分组,最后,对于每一天,找到平均值。

于 2015-04-14T12:49:22.173 回答
0

我不熟悉deedle,但我很好奇,发现了这个 http://bluemountaincapital.github.io/Deedle/tutorial.html

基于此,我会尝试:

let dateTimeFilter = [ ... ] //todo add the dateTimes that are currently of interest
// in the tutorial it was like this [ for d in 2 .. 4 -> DateTime(2013, 1, d) ]

let filtered = csv_temp.Rows.[dateTimeFilter]

let result = (filtered?Close * filtered?Volume) |> Stats.mean
于 2015-04-14T08:04:16.940 回答