rename OHLCValue -> OHLCEvent
This commit is contained in:
@ -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)",
|
||||
|
||||
44
src/main/java/ats/plugin/OHLCEvent.java
Normal file
44
src/main/java/ats/plugin/OHLCEvent.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
2
test.epl
2
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)
|
||||
|
||||
Reference in New Issue
Block a user