0

I am unable to solve an Esper problem. I have to calculate Max and Min of 24 hours and then i have to check if tick price goes above this value ( This has to be done on multiple securities .) Here is the code which i am using. But i am betting alot of performance hit and getting an event fired more than once.

create context
GroupSecurity
partition by 
security
from 
Tick;

context
GroupSecurity
select
currentData.last, max(groupedData.last)
from
Tick as currentData unidirectional, Tick.win:time_batch(24 hour) as groupedData
having
currentData.last > max(groupedData.last);

How can i Improve this code?

Goibniu
  • 2,212
  • 3
  • 34
  • 38
Ahmad.Masood
  • 1,289
  • 3
  • 21
  • 40

1 Answers1

1

The "Tick.win:time_batch(24 hour)" tells the engine to retain in memory all 24 hours of Tick events that may arrive, and only spit these out after 24 hours. I think a better approach would be to have the engine compute say 1-minute maximums and take the 1-minute maximums for 24 hours and take the max of that, i.e. retain and build a max from no more then 24*60 rows where each row keeps a 1-minute max.

user650839
  • 2,594
  • 1
  • 13
  • 9