Hi, I currently have a simple project in ESP which consists of a Source window, followed by a Pattern Window. The input stream is from a csv which has the following columns: id, stock, stock_price and amount_purchased. Using the Pattern window, I would like to detect when a certain id has purchased a certain stock in two separate events, with the second purchase having been for a lower price. -- Define start event that returns true for every event and sets values for variables in context
function event_function(event, context)
return true, {id=event.id, stock=event.stock, old_price=event.stock_price, amount_purchased_old=event.amount_purchased}
end
-- Define event that returns true if current trade price is less than previous trade price
function price_dec(event,context)
if (event.id == context.data.id and event.stock == context.data.stock and event.stock_price < context.data.old_price)
then
return true, {new_price=event.stock_price, id=event.id, stock=event.stock, old_price=context.data.old_price, amount_purchased_new=event.amount_purchased, amount_purchased_old=context.data.amount_purchased_old}
end
return false
end What I am noticing is that my Pattern window does NOT seem to pick up the pattern properly if the first input row (first row of the csv file) is the start of the pattern. Does anyone know why this may be the case?
... View more