4

I am using Complex Event Processing (Esper) technology to provide a real-time candlestick calculations in my system. I am doing fine with calculating values, however I find it difficult to ensure that candle window starts at full minutes (for one minute candle) and ends before the next minute starts (i.e. candle 1[06:00.000 - 06:00.999], candle 2[06:01.000 - 06:01.999], etc... ).

Is there a pattern or command in Esper's query language that is able to provide such functionality?

I'd appreciate constructive comments and directions.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Michal
  • 93
  • 2
  • 8

2 Answers2

3

In Esper you can use a pattern to fire every minute at the zero second, i.e.
insert into TriggerEvent select * from pattern[pattern[every timer:interval(1 min).] // named window to hold candle data, compute next candle on TriggerEvent select * from NamedWindowCandle .... // delete old data on TriggerEvent delete from NamedWindowCandle

-rg

2

Local time is often different from exchange time, also there is latency in delivering tick data. Minute bars are often computed using exchange timestamp. The exchange timestamp value must be extracted from tick events. New minute bar event is sent when the tick timestamps enter new minute.

lsac
  • 21
  • 2