rename OHLCValue -> OHLCEvent

This commit is contained in:
2018-06-20 22:28:42 -07:00
parent ced385ef8a
commit ff5fa69e7d
5 changed files with 51 additions and 63 deletions

View File

@ -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)",

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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)