use of org.knowm.xchange.hitbtc.v2.dto.HitbtcOrderBook in project XChange by knowm.
the class HitbtcMarketDataDemo method raw.
private static void raw(HitbtcMarketDataServiceRaw marketDataService) throws IOException {
HitbtcTicker ticker = marketDataService.getHitbtcTicker(CurrencyPair.BTC_USD);
System.out.println("BTC/USD Ticker: " + ticker.toString());
Map<String, HitbtcTicker> tickers = marketDataService.getHitbtcTickers();
System.out.println("All Tickers: " + tickers.toString());
// Get the latest order book data for BTC/USD
HitbtcOrderBook orderBook = marketDataService.getHitbtcOrderBook(CurrencyPair.BTC_USD);
System.out.println("Current Order Book size for BTC/USD: " + (orderBook.getAsks().length + orderBook.getBids().length));
System.out.println(orderBook);
}
use of org.knowm.xchange.hitbtc.v2.dto.HitbtcOrderBook in project XChange by knowm.
the class HitbtcStreamingMarketDataService method getOrderBook.
@Override
public Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... args) {
String pair = currencyPair.base.toString() + currencyPair.counter.toString();
String channelName = getChannelName("orderbook", pair);
final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper();
Observable<JsonNode> jsonNodeObservable = service.subscribeChannel(channelName);
return jsonNodeObservable.map(s -> mapper.readValue(s.toString(), HitbtcWebSocketOrderBookTransaction.class)).map(s -> {
HitbtcWebSocketOrderBook hitbtcOrderBook = s.toHitbtcOrderBook(orderbooks.getOrDefault(currencyPair, null));
orderbooks.put(currencyPair, hitbtcOrderBook);
return HitbtcAdapters.adaptOrderBook(hitbtcOrderBook.toHitbtcOrderBook(), currencyPair);
});
}
Aggregations