Hi Luis: congrats on tasking the CEP community with another apparent
conundrum! I drafted a reply yesterday but thought it too obvious -
today I see the debate continues so here are my thoughts...
This is basically a query on an operational data (or event) store of
stock prices. It's time based (ie a temporal query). You could use EP
to monitor the events but (as I think has been discussed / you
surmise) there is an initial query part too.
1. What was the stock price at time t-5? Was this above $70?
2. Were there any events that changed that in t to t-4.999999...? Was
this above $70?
I think Ophers blog on this topic is quite correct (albeit long!) -
http://epthinking.blogspot.com/2009/01/on-event-processing-and-some.html .
In providing a solution for this: probably I would want to know if
(a) this was a generic problem:
e.g. for any period p I want to know if stock S had a f(value)
relative to some other value
(b) whether this was a continuous query or a static one (in the
business sense)
e.g. do I need to know the result for now to now-5 for all now's?
(b) whether the volumes require data grid storage or not
e.g. whether I need to consider data access considerations.
(c) how often these queries would be required and their performance
requirements
e.g. is this a non-performance-critical occasional report, or a key
application?
For example, it might make sense to relate all events (ie use a linked
list) so I can (a) query / find the set s of all price events in time
period p and (b) find the preceding event for the earliest member of s.
In TIBCO, of course we can define whatever we want to store (as the
derived event object), including references to other events. Typically
this sort of problem would require a data grid storage, but of course
you could also make use of some other storage mechanism for the
historic query. But essentially it is 2 queries... with some care
needed for query/store latency and time.
Cheers
Paul Vincent for Tibco
--- In CEP-Interest@yahoogroups.com, "pureza_l" <pureza_l@...> wrote:
>
> Hi,
>
> I have the good old StockTrades stream with two fields: symbol and
> price. I'm trying to answer the following question "Were Company X
> stock actions priced above $70 during any moment of the last 5
minutes?".
>
> Unfortunately, using a simple time-based sliding window won't work. To
> see why, imagine there were only two price updates: the first, at
> 10:54 am stated that stocks were at $71. The second, 2 minutes later,
> notified that the stocks went down to $69. Now imagine that the above
> question was posed at 11:00 am (of the same day). We, humans, know
> that the answer is "yes" because the price was $71 between 10:54 and
> 10:56. But the first event is outside the 5 minutes window and will
> thus be ignored by the system.
>
> How would you solve this?
>
> Thanks,
>
> Luís Pureza
>