From 104eb216b51e2afe66258f4cfd183eda66d547bc Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Wed, 14 Nov 2018 18:31:53 -0800 Subject: [PATCH] Make DateTime available without package prefix in epl --- epl/trading_system_1.epl | 20 ++++++++++---------- src/main/java/EsperProcessor.java | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/epl/trading_system_1.epl b/epl/trading_system_1.epl index 743d7c8..0273897 100644 --- a/epl/trading_system_1.epl +++ b/epl/trading_system_1.epl @@ -97,7 +97,7 @@ insert into SMACloseStream -- A stream that feeds B1 and B2. Each event contains a double -- precision floating point value "low", and a timestamp called -- "time". -create schema BStream as (low double, time org.joda.time.DateTime) +create schema BStream as (low double, time DateTime) -- Listen to the last "RefSize" number of SMACloseStream events. Look -- for an OHLC bar with a lower average close than its neighbors. Add @@ -111,7 +111,7 @@ insert into BStream -- Define B1 to contain the same fields as BStream -create schema B1 (low double, time org.joda.time.DateTime) +create schema B1 (low double, time DateTime) -- B1 contains the most recent low value and time from BStream. -- This is the last time an average close was lower @@ -122,14 +122,14 @@ insert into B1 select prev(0, low) as low, prev(0, time) as time -- B2 contains the *second* most recent occurrence in BStream, but is -- otherwise the same as B1. -create schema B2 (low double, time org.joda.time.DateTime) +create schema B2 (low double, time DateTime) insert into B2 select prev(1, low) as low, prev(1, time) as time from BStream#length(RefSize) -- A stream that feeds P1 and P2. -create schema PStream as (low double, time org.joda.time.DateTime) +create schema PStream as (low double, time DateTime) -- Find an OHLC bar with a higher average close than its neighbors. -- Add that low value and its timestamp to the stream. @@ -142,13 +142,13 @@ insert into PStream -- This is the last time an average close was higher -- than the ones before and after. -- Since the time is included in the event, no separate PT1 is needed. -create schema P1 (low double, time org.joda.time.DateTime) +create schema P1 (low double, time DateTime) insert into P1 select prev(0, low) as low, prev(0, time) as time from PStream#length(RefSize) -- P2 contains the second most recent occurrence in PStream. -create schema P2 (low double, time org.joda.time.DateTime) +create schema P2 (low double, time DateTime) insert into P2 select prev(1, low) as low, prev(1, time) as time from PStream#length(RefSize) @@ -167,9 +167,9 @@ insert into MaxHigh3Window select max(high) as high from OHLCStream#length(3) --- Long entry events contain the current tick's midpoint value and --- timestamp. -create schema LongEntryStream as (current BigDecimal, time org.joda.time.DateTime, instrument String) +-- Long entry events contain the current tick's midpoint value, +-- timestamp, and instrument name. +create schema LongEntryStream as (current BigDecimal, time DateTime, instrument String) -- The long entry calc below is translated from this entry in the -- spreadsheet: @@ -202,7 +202,7 @@ insert into LongEntryStream -- -- LongEntryDistinct filters out duplicate LongEntryStream events, -- leaving a maximum of one event per tick. -create schema LongEntryDistinct as (current BigDecimal, time org.joda.time.DateTime, +create schema LongEntryDistinct as (current BigDecimal, time DateTime, instrument String, units int) insert into LongEntryDistinct diff --git a/src/main/java/EsperProcessor.java b/src/main/java/EsperProcessor.java index 755ae71..eb6e384 100644 --- a/src/main/java/EsperProcessor.java +++ b/src/main/java/EsperProcessor.java @@ -9,6 +9,7 @@ import com.espertech.esper.client.StatementAwareUpdateListener; import com.espertech.esper.client.UpdateListener; import com.espertech.esper.client.time.CurrentTimeEvent; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +37,7 @@ public class EsperProcessor implements TickProcessor { config.addEventType(TickEvent.class); config.addEventType(OHLCEvent.class); config.addEventType(OHLCValueEvent.class); + config.addEventType(DateTime.class); // add OHLC plugin config.addPlugInView("ATS", "OHLC", OHLCPlugInViewFactory.class.getName());