From ff5fa69e7dcce91221ca863dab1f969f2f1ea6b4 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Wed, 20 Jun 2018 22:28:42 -0700 Subject: [PATCH] rename OHLCValue -> OHLCEvent --- src/main/java/EsperProcessor.java | 8 ++- src/main/java/ats/plugin/OHLCEvent.java | 44 ++++++++++++++++ src/main/java/ats/plugin/OHLCPlugInView.java | 6 +-- src/main/java/ats/plugin/OHLCValue.java | 54 -------------------- test.epl | 2 +- 5 files changed, 51 insertions(+), 63 deletions(-) create mode 100644 src/main/java/ats/plugin/OHLCEvent.java delete mode 100644 src/main/java/ats/plugin/OHLCValue.java diff --git a/src/main/java/EsperProcessor.java b/src/main/java/EsperProcessor.java index f914091..23da4d3 100644 --- a/src/main/java/EsperProcessor.java +++ b/src/main/java/EsperProcessor.java @@ -1,7 +1,6 @@ import ats.plugin.OHLCPlugInViewFactory; -import ats.plugin.OHLCTick; import ats.plugin.OHLCUpdateListener; -import ats.plugin.OHLCValue; +import ats.plugin.OHLCEvent; import com.espertech.esper.client.Configuration; import com.espertech.esper.client.EPServiceProvider; import com.espertech.esper.client.EPServiceProviderManager; @@ -34,9 +33,8 @@ public class EsperProcessor implements TickProcessor { config.addEventType(TickEvent.class); config.addEventType(LongEntryEvent.class); //config.addVariable("FOO", int.class, 12); + config.addEventType(OHLCEvent.class); - config.addEventType("OHLCTick", OHLCTick.class); - config.addEventType("OHLCValue", OHLCValue.class); config.addPlugInView("ATS", "OHLC", OHLCPlugInViewFactory.class.getName()); engine = EPServiceProviderManager.getDefaultProvider(config); @@ -56,7 +54,7 @@ public class EsperProcessor implements TickProcessor { // double l = (double)newData[0].get("last"); // double x = (double)newData[0].get("max"); // double n = (double)newData[0].get("min"); - // log.info("OHLCValue: {} {} {} {}", f,l,x,n); + // log.info("OHLC: {} {} {} {}", f,l,x,n); }); // addStatement("select * from TickEvent#groupwin(instrument)#ohlcbarminute(timestamp, midDouble)", diff --git a/src/main/java/ats/plugin/OHLCEvent.java b/src/main/java/ats/plugin/OHLCEvent.java new file mode 100644 index 0000000..99eaf17 --- /dev/null +++ b/src/main/java/ats/plugin/OHLCEvent.java @@ -0,0 +1,44 @@ +package ats.plugin; + +import org.joda.time.DateTime; + +/** + * OHLCEvent stores one bar of OHLC info. + */ +public class OHLCEvent { + private DateTime time; + private double open; + private double high; + private double low; + private double close; + + + public OHLCEvent(DateTime time, + double open, double high, + double low, double close) + { + this.time = time; + this.open = open; + this.high = high; + this.low = low; + this.close = close; + } + + public DateTime getTime() {return time;} + + public Double getOpen() { return open; } + + public Double getHigh() { return high; } + + public Double getLow() { return low; } + + public Double getClose() { return close; } + + /** + * Return a human readable representation of this event. + */ + public String toString() { + return String.format("OHLCEvent[%s, open=%s, high=%s, low=%s, close=%s]", + time, open, high, low, close); + } +} diff --git a/src/main/java/ats/plugin/OHLCPlugInView.java b/src/main/java/ats/plugin/OHLCPlugInView.java index 647e1f2..adae554 100644 --- a/src/main/java/ats/plugin/OHLCPlugInView.java +++ b/src/main/java/ats/plugin/OHLCPlugInView.java @@ -231,7 +231,7 @@ public class OHLCPlugInView extends ViewSupport { private void postData() { if (open == null) return; - OHLCValue value = new OHLCValue(windowStartTime, open, high, low, close); + OHLCEvent value = new OHLCEvent(windowStartTime, open, high, low, close); // send EventAdapterService service = agentContext.getStatementContext().getEventAdapterService(); @@ -261,8 +261,8 @@ public class OHLCPlugInView extends ViewSupport { protected static EventType getEventType(EventAdapterService service) { - return service.addBeanType(OHLCValue.class.getName(), - OHLCValue.class, + return service.addBeanType(OHLCEvent.class.getName(), + OHLCEvent.class, false, false, false); } diff --git a/src/main/java/ats/plugin/OHLCValue.java b/src/main/java/ats/plugin/OHLCValue.java deleted file mode 100644 index 21aad38..0000000 --- a/src/main/java/ats/plugin/OHLCValue.java +++ /dev/null @@ -1,54 +0,0 @@ -package ats.plugin; - -import org.joda.time.DateTime; - -/** - * OHLCValue stores one bar of OHLC info. - */ -public class OHLCValue { - private DateTime time; - private double open; - private double high; - private double low; - private double close; - - - public OHLCValue(DateTime time, - double open, double high, - double low, double close) - { - this.time = time; - this.open = open; - this.high = high; - this.low = low; - this.close = close; - } - - public DateTime getTime() { - return time; - } - - public Double getOpen() { - return open; - } - - public Double getHigh() { - return high; - } - - public Double getLow() { - return low; - } - - public Double getClose() { - return close; - } - - /** - * Return a human readable representation of this event. - */ - public String toString() { - return String.format("OHLCValue[%s,open=%s,high=%s,low=%s,close=%s]", - time, open, high, low, close); - } -} diff --git a/test.epl b/test.epl index efce29e..fac6251 100644 --- a/test.epl +++ b/test.epl @@ -28,7 +28,7 @@ on TickEvent as t set InTradingHours = EPLHelpers.getHour(t.time) < EndTimeHour) -- A stream of OHLC values -create variant schema OHLCStream as OHLCValue +create variant schema OHLCStream as OHLCEvent insert into OHLCStream select * from TickEvent#OHLC(Interval, time, midDouble)