public Map<String, Object> adaptTickerUpdate(String data) {
Map<String, Object> resultMap = new HashMap<String, Object>();
CoinfloorTicker rawRetObj;
try {
rawRetObj = streamObjectMapper.readValue(data, CoinfloorTicker.class);
} catch (IOException e) {
throw new ExchangeException("JSON parse error", e);
}
Ticker genericTicker;
synchronized (cachedDataSynchronizationObject) {
// base & counter currencies hard coded in; no way to make it dynamic with return data - may change over time.
BigDecimal last = (rawRetObj.getLast().doubleValue() == 0 ? cachedTicker.getLast() : rawRetObj.getLast());
BigDecimal bid = (rawRetObj.getBid().doubleValue() == 0 ? cachedTicker.getBid() : rawRetObj.getBid());
BigDecimal ask = (rawRetObj.getAsk().doubleValue() == 0 ? cachedTicker.getAsk() : rawRetObj.getAsk());
BigDecimal low = (rawRetObj.getLow().doubleValue() == 0 ? cachedTicker.getLow() : rawRetObj.getLow());
BigDecimal high = (rawRetObj.getHigh().doubleValue() == 0 ? cachedTicker.getHigh() : rawRetObj.getHigh());
BigDecimal volume = (rawRetObj.getVolume().doubleValue() == 0 ? cachedTicker.getVolume() : rawRetObj.getVolume());
genericTicker =
new Ticker.Builder().currencyPair(new CurrencyPair(rawRetObj.getBase().toString(), rawRetObj.getCounter().toString())).last(last).bid(bid).ask(ask).low(low)
.high(high).volume(volume).build();
cachedTicker = genericTicker;
}
resultMap.put("generic", genericTicker);