I've the following problem. I've a set of OHLCV (Open, High, Low, Close, Volume) data for a symbol, with the following structure:
struct OHLCV {
double Open{0.0};
double High{0.0};
double Low{0.0};
double Close{0.0};
double Volume{0.0};
};
every data cover a time frame of 1 hour. I need to take many of them and then calculate the cumulative OHLCV. For example if need to calculate the OHLCV for a day from 24 hourly OHLCV.
for creating the cumulative OHLCV from a set of them I need to:
- Take the first Open value;
- Take the last Close value;
- Take the highest High value;
- Take the lowest Low value;
- Take the sum of Volume values
I'd like to know if it's possible to use boost::accumulator
for this purpose so I can write code like following one:
using namespace boost::accumulators;
std::vector<OHLCV> rawData;
// creating CustomFeatures and OHLCVCumulative...
accumulator_set<OHLCV, CustomFeatures> ohlcvAcc;
for (const auto& ohlcv : rawData) {
ohlcvAcc(ohlcv);
}
auto cumulativeOHLCV = OHLCVCumulative(ohlcvAcc);
It's possible to do something like this? Or there's a better solution?