ticks implement VizMappable now

This commit is contained in:
2019-02-11 16:52:30 -08:00
parent c54f24c0b2
commit 4444482efa
2 changed files with 37 additions and 2 deletions

View File

@ -1,10 +1,14 @@
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import ats.viz.VizMappable;
/** /**
* TrueFXTickEvent holds a single tick read from TrueFX data archive * TrueFXTickEvent holds a single tick read from TrueFX data archive
* csv file. * csv file.
@ -13,7 +17,7 @@ import org.joda.time.DateTime;
* EUR/USD,20170102 00:00:00.803,1.0523,1.05307 * EUR/USD,20170102 00:00:00.803,1.0523,1.05307
*/ */
@JsonPropertyOrder({ "instrument", "time", "bid", "ask" }) @JsonPropertyOrder({ "instrument", "time", "bid", "ask" })
public class TrueFXTickEvent extends TickEvent { public class TrueFXTickEvent extends TickEvent implements VizMappable {
@JsonFormat(pattern="yyyyMMdd HH:mm:ss.SSS") @JsonFormat(pattern="yyyyMMdd HH:mm:ss.SSS")
private DateTime time; private DateTime time;
private String instrument; private String instrument;
@ -97,6 +101,17 @@ public class TrueFXTickEvent extends TickEvent {
return n.replace('/', '_'); return n.replace('/', '_');
} }
/**
* Return a map of property names to object values of the
* properties that should be included in the visualization log.
*/
public Map<String,Object> toVizPropertyMap() {
Map<String,Object> map = new HashMap<String,Object>();
map.put("time", time);
map.put("mid", getMid());
return map;
}
/** /**
* Return a human readable representation of this event. * Return a human readable representation of this event.
*/ */

View File

@ -1,11 +1,17 @@
package ats.plugin; package ats.plugin;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import ats.viz.VizMappable;
/** /**
* OHLCEvent stores one bar of OHLC info. * OHLCEvent stores one bar of OHLC info.
*/ */
public class OHLCEvent { public class OHLCEvent implements VizMappable {
private DateTime time; private DateTime time;
private double open; private double open;
private double high; private double high;
@ -38,6 +44,20 @@ public class OHLCEvent {
public Double getClose() { return close; } public Double getClose() { return close; }
/**
* Return a map of property names to object values of the
* properties that should be included in the visualization log.
*/
public Map<String,Object> toVizPropertyMap() {
Map<String,Object> map = new HashMap<String,Object>();
map.put("time", time);
map.put("open", open);
map.put("high", high);
map.put("low", low);
map.put("close", close);
return map;
}
/** /**
* Return a human readable representation of this event. * Return a human readable representation of this event.
*/ */