more tabs to spaces

This commit is contained in:
2018-06-20 22:31:06 -07:00
parent 25a2c19ecb
commit a03ba9a883
2 changed files with 92 additions and 92 deletions

View File

@ -9,72 +9,72 @@ import com.fasterxml.jackson.annotation.JsonFormat;
* {"type":"PRICE","time":"2018-04-05T20:35:20.983907480Z","bids":[{"price":"1.22376","liquidity":10000000}],"asks":[{"price":"1.22386","liquidity":10000000}],"closeoutBid":"1.22361","closeoutAsk":"1.22401","status":"tradeable","tradeable":true,"instrument":"EUR_USD"} * {"type":"PRICE","time":"2018-04-05T20:35:20.983907480Z","bids":[{"price":"1.22376","liquidity":10000000}],"asks":[{"price":"1.22386","liquidity":10000000}],"closeoutBid":"1.22361","closeoutAsk":"1.22401","status":"tradeable","tradeable":true,"instrument":"EUR_USD"}
*/ */
public class OANDATickEvent extends TickEvent { public class OANDATickEvent extends TickEvent {
public String type; public String type;
private DateTime time; private DateTime time;
public PriceBucket[] bids; public PriceBucket[] bids;
public PriceBucket[] asks; public PriceBucket[] asks;
public BigDecimal closeoutBid; public BigDecimal closeoutBid;
public BigDecimal closeoutAsk; public BigDecimal closeoutAsk;
public String status; public String status;
public boolean tradeable; public boolean tradeable;
private String instrument; private String instrument;
/** /**
* @return the instrument * @return the instrument
*/ */
@Override @Override
public String getInstrument() { public String getInstrument() {
return instrument; return instrument;
} }
/** /**
* @param instrument the instrument to set * @param instrument the instrument to set
*/ */
public void setInstrument(String instrument) { public void setInstrument(String instrument) {
this.instrument = instrument; this.instrument = instrument;
} }
/** /**
* @return the time * @return the time
*/ */
@Override @Override
public DateTime getTime() { public DateTime getTime() {
return time; return time;
} }
/** /**
* @param time the time to set * @param time the time to set
*/ */
public void setTime(DateTime time) { public void setTime(DateTime time) {
this.time = time; this.time = time;
} }
/** /**
* @return the bid * @return the bid
*/ */
@Override @Override
public BigDecimal getBid() { public BigDecimal getBid() {
return bids[0].price; return bids[0].price;
} }
/** /**
* @return the ask * @return the ask
*/ */
@Override @Override
public BigDecimal getAsk() { public BigDecimal getAsk() {
return asks[0].price; return asks[0].price;
} }
/** /**
* @return the midprice between bid and ask * @return the midprice between bid and ask
*/ */
@Override @Override
public BigDecimal getMid() { public BigDecimal getMid() {
return getMid(asks[0].price, bids[0].price); return getMid(asks[0].price, bids[0].price);
} }
public String toString() { public String toString() {
return String.format("OANDATickEvent[%s,%s,%s]", getTime(), getInstrument(), getMid()); return String.format("OANDATickEvent[%s, %s, %s]", getTime(), getInstrument(), getMid());
} }
} }

View File

@ -4,43 +4,43 @@ import org.joda.time.DateTime;
public abstract class TickEvent { public abstract class TickEvent {
/** /**
* @return the tick time * @return the tick time
*/ */
public abstract DateTime getTime(); public abstract DateTime getTime();
/** /**
* @return the trading instrument * @return the trading instrument
*/ */
public abstract String getInstrument(); public abstract String getInstrument();
/** /**
* @return the bid price * @return the bid price
*/ */
public abstract BigDecimal getBid(); public abstract BigDecimal getBid();
/** /**
* @return the ask price * @return the ask price
*/ */
public abstract BigDecimal getAsk(); public abstract BigDecimal getAsk();
/** /**
* @return the midprice between bid and ask * @return the midprice between bid and ask
*/ */
public abstract BigDecimal getMid(); public abstract BigDecimal getMid();
/** /**
* Calculate the midpoint between two values. * Calculate the midpoint between two values.
*/ */
public static BigDecimal getMid(BigDecimal a, BigDecimal b) { public static BigDecimal getMid(BigDecimal a, BigDecimal b) {
BigDecimal diff = a.subtract(b).abs(); BigDecimal diff = a.subtract(b).abs();
return a.min(b).add(diff.divide(new BigDecimal(2))); return a.min(b).add(diff.divide(new BigDecimal(2)));
} }
/** /**
* Calculate the midpoint between two values. * Calculate the midpoint between two values.
*/ */
public double getMidDouble() { public double getMidDouble() {
return getMid().doubleValue(); return getMid().doubleValue();
} }
} }