I have a large database of of 1minute OHLCV data. I'm trying to aggregate this data, into 1 hour data. The main Idea is to, in the future, replace this offline data source with some live data source, so the aggregation in the event would help us a lot.
I'm struggling to do it with Reactive Extensions. So far i have the following:
source.ListBars(coins)
.ToObservable()
.Select(t =>
{
var date = t.Date - (t.Date - timeframe);
return new
{
Date = date,
t.Open,
t.High,
t.Low,
t.Close,
t.Volume
};
})
.GroupByUntil(t => t.Date, t => t.DistinctUntilChanged(u => u.Date))
.Select(t => t.ToEnumerable().ToList())
.Select(t => new
{
t[0].Date,
t[0].Open,
High = t.Max(x => x.High),
Low = t.Min(x => x.Low),
t[^1].Close,
Volume = t.Sum(x => x.Volume)
})
.Subscribe(bar => Log.Information("D:{date:dd/MM/yyyy HH:mm:ss zzz}, O:{open:f4}, H:{high:f4}, L:{low:f4}, C:{close:f4}, V:{volume:f4}",
bar.Date.ToDateTime(), bar.Open, bar.High, bar.Low, bar.Close, bar.Volume));
But, it's not working. Any of you know how to accomplish this?
thank you in advance!