Trying to use Deedle to parse csv file and produce Open
High
Low
Close
values based on lastPrice
value
Bellow is the sample from csv that contains tick data (each line a is a tick interval):
"time", "lastPrice", "bidPrice", "askPrice", "volume"
20230208 050001 0040000;4175.25;4175;4175.25;3
20230208 050001 1040000;4175.25;4175.25;4175.5;1
20230208 050001 1040000;4175.25;4175.25;4175.5;2
20230208 050001 3520000;4175.25;4175;4175.25;1
20230208 050007 1880000;4175.25;4175;4175.25;1
20230208 050007 8520000;4175.25;4175;4175.25;1
20230208 050008 8280000;4175.25;4175;4175.25;1
20230208 050010 2920000;4175;4175;4175.25;1
20230208 050010 2920000;4175;4175;4175.25;1
20230208 050010 2920000;4175;4175;4175.25;1
20230208 050010 2920000;4175;4175;4175.25;1
20230208 050010 2920000;4175;4175;4175.25;1
20230208 050010 3520000;4175;4175;4175.25;1
Following is the example as far as making use of ResampleEquivalence
extension on lastPrice
column and returning OHLC
values based on 2000
ticks interval (all in all to resample 1 tick and produce 2000 ticks interval)
var df = Frame.ReadCsv("./Data/ES 03-23.Last.txt", hasHeaders: false, separators: ";").IndexColumnsWith(new[] { "time", "lastPrice", "bidPrice", "askPrice", "volume" });
var prices = df["lastPrice"];
var agg = prices.ResampleEquivalence(kv => {
return kv / 2000;
}
).Select(data =>
new
{
Timestamp = data.ToString(),
Open = data.Value.FirstValue(),
High = data.Value.Max(),
Close = data.Value.LastValue(),
Low = data.Value.Min()
});
Frame.FromRecords(agg).Print();
It all seem to work as expected, but can't seem to figure out how to output Time
along with OHLC which should be MAX(Time) for that 2000 tick interval?