Hi guys,
I am trying to store ohlcv data obtained from binance api.
I am new to fluxdb and would appreciate some help.
The method I use sends me, already calculated the candles with the following information (timestamp, open, high, low, close, volume) in the interval of 1 minute.
Once this information is stored, I would like to be able to query this information but in the context of a larger interval, for example 5 minutes, 1 hour, 4 hours, etc.
I have been able to see in other messages here how that query would be constructed if what we had stored were stock trades, but I have precalculated 1 minute candlesticks.
My configuration is as follows:
The measurement is called “ohlcv”
I have a “pair” tag that identifies the currency pair.
In that bucket I have the 1 minute candlesticks of all currency pairs.
Each row has the fields:
- open
- high
- low
- close
- volume
Suppose I want to query the candlesticks of an interval of 5m.
Conceptually I know that to obtain the equivalent candlestick opening in an interval of 5m I have to:
- In the case of the “open” field I have to select candlestick within that interval (the first candlestick of the five).
- In the case of the “close” field I have to select the “closing” field of the last candlestick (the last candlestick of the 5).
- In the case of the “high” field I have to select the “high” field of the candlestick in which the high field reached a higher price.
- In the case of the “low” field, I have to select the “low” field of the candlestick in which the “low” field reached a lower price.
- Finally, in the case of the “volume” field I have to calculate the sum of all the values ​​of the “volume” field of all the candlesticks in the interval.
Thank you so much.