0

I've got an esper query for pulling market data. It looks like

select * from L1Quote(Symbol='MSFT')

This will fire when ever a new quote occurs. I require a first quote/event to do some initial setup. This is no problem for symbols where events/quotes fire every second but for some symbols you won't get a new quote event for a minute.

Working under the assumption that there have been quote events before this expressions is setup. Is there a way to force output when the expression is first parsed? ie is there a way to say, give me the last event when the expression starts?

4

2 回答 2

1

您只需要创建一个窗口来存储最新报价,然后对其进行查询。

在您的 Esper EPL 中:

//the L1Quote event definition
create schema L1Quote(Symbol string, ...)

//create a window with the same definition as L1Quote and it retain the latest event by Symbol
create window L1Quotes.std:unique(Symbol) as select * from L1Quote

//insert all incoming quotes into the window we created
insert into L1Quotes select * from L1Quote

您的客户端将需要查询窗口并订阅它:

//subscribe to quote updates
EPStatement statement = epAdmin.createEPL("select * from L1Quotes(Symbol='MSFT')");
statement.addListener([my listener]);

//get the latest quote
epEngine.executeQuery("select * from L1Quotes(Symbol='MSFT')");
于 2014-10-03T02:15:32.620 回答
0

Esper 不会在内存中保留旧事件(除非您的 EPL 使用数据窗口或模式指定)。因此,鉴于您提供的查询,它没有过去的事件。

于 2014-10-02T16:29:42.497 回答