use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker in project XChange by knowm.
the class TickerDemo method raw.
private static void raw(BitfinexMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest ticker data showing BTC to USD
BitfinexTicker ticker = marketDataService.getBitfinexTicker("btcusd");
System.out.println(ticker.toString());
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker in project XChange by knowm.
the class BitfinexAdapters method adaptTicker.
public static Ticker adaptTicker(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTicker bitfinexTicker) {
BigDecimal last = bitfinexTicker.getLastPrice();
BigDecimal bid = bitfinexTicker.getBid();
BigDecimal bidSize = bitfinexTicker.getBidSize();
BigDecimal ask = bitfinexTicker.getAsk();
BigDecimal askSize = bitfinexTicker.getAskSize();
BigDecimal high = bitfinexTicker.getHigh();
BigDecimal low = bitfinexTicker.getLow();
BigDecimal volume = bitfinexTicker.getVolume();
BigDecimal percentageChange = bitfinexTicker.getDailyChangePerc().multiply(new BigDecimal("100"), new MathContext(8));
CurrencyPair currencyPair = CurrencyPairDeserializer.getCurrencyPairFromString(bitfinexTicker.getSymbol().substring(1));
return new Ticker.Builder().currencyPair(currencyPair).last(last).bid(bid).ask(ask).high(high).low(low).volume(volume).bidSize(bidSize).askSize(askSize).percentageChange(percentageChange).build();
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker in project XChange by knowm.
the class BitfinexAdapters method adaptTicker.
public static Ticker adaptTicker(BitfinexTicker bitfinexTicker, CurrencyPair currencyPair) {
BigDecimal last = bitfinexTicker.getLast_price();
BigDecimal bid = bitfinexTicker.getBid();
BigDecimal bidSize = bitfinexTicker.getBidSize();
BigDecimal ask = bitfinexTicker.getAsk();
BigDecimal askSize = bitfinexTicker.getAskSize();
BigDecimal high = bitfinexTicker.getHigh();
BigDecimal low = bitfinexTicker.getLow();
BigDecimal volume = bitfinexTicker.getVolume();
Date timestamp = DateUtils.fromMillisUtc((long) (bitfinexTicker.getTimestamp() * 1000L));
return new Ticker.Builder().currencyPair(currencyPair).last(last).bid(bid).bidSize(bidSize).ask(ask).askSize(askSize).high(high).low(low).volume(volume).timestamp(timestamp).build();
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker in project XChange by knowm.
the class BitfinexWebSocketTickerTransaction method toBitfinexTicker.
public BitfinexTicker toBitfinexTicker() {
BigDecimal bid = new BigDecimal(tickerArr[0]);
BigDecimal bidSize = new BigDecimal(tickerArr[1]);
BigDecimal ask = new BigDecimal(tickerArr[2]);
BigDecimal askSize = new BigDecimal(tickerArr[3]);
BigDecimal mid = ask.subtract(bid);
BigDecimal low = new BigDecimal(tickerArr[9]);
BigDecimal high = new BigDecimal(tickerArr[8]);
BigDecimal last = new BigDecimal(tickerArr[6]);
// Xchange-bitfinex adapter expects the timestamp to be seconds since Epoch.
double timestamp = System.currentTimeMillis() / 1000;
BigDecimal volume = new BigDecimal(tickerArr[7]);
return new BitfinexTicker(mid, bid, bidSize, ask, askSize, low, high, last, timestamp, volume);
}
Aggregations