Hello,
consider using Kapacitor as a real-time 1m candle builder, but I’m not sure that is possible. I got started with the documentation and tried to write some TickScripts. I think that I can use stream node for this purpose something like this:
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(‘security’)
|window()
.align()
.period(1m)
.every(1m)
var max = data
|max(‘price’)
.as(‘high’)
var min = data
|min(‘price’)
.as(‘low’)
var open = data
|first(‘price’)
.as(‘open’)
var close = data
|last(‘price’)
.as(‘close’)
var sum = data
|sum(‘volume’)
.as(‘volume’)
max
|join(min, sum, open, close)
.as(‘high’, ‘low’, ‘volume’, ‘open’, ‘close’)
And it looks like this works fine, but this is not real-time, because it builds a candle and pushes it one a minute. That’s great, but I want to push a candle on each streaming data. I can remove every(1m) from the script, but in this case align doesn’t work.
So, my question is…can I use Kapacitor to build a real-time candle? If yes, which approach should I use? Probably I can combine several nodes to get a result.