ESPER:查找24小时的最大值和最小值,并检查价格是否高于之前24小时的最大值

时间:2013-09-23 07:57:10

标签: stock esper

我无法解决Esper问题。我必须计算24小时的最大值和最小值,然后我必须检查价格是否高于此值(这必须在多个证券上完成。)这是我正在使用的代码。但我打赌很多表现受到打击并且不止一次发生了一次事件。

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);

如何改进此代码?

1 个答案:

答案 0 :(得分:1)

“Tick.win:time_batch(24小时)”告诉引擎在内存中保留所有可能到达的24小时Tick事件,并且仅在24小时后将其吐出。 我认为一个更好的方法是让引擎计算出1分钟的最大值,并在24小时内取1分钟的最大值并取最大值,即从不超过24 * 60行保留并构建最大值行保持最多1分钟。