use of org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook in project XChange by knowm.
the class LivecoinMarketDataService method getOrderBook.
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
try {
int depth = 50;
if (args != null && args.length > 0) {
if (args[0] instanceof Number) {
Number arg = (Number) args[0];
depth = arg.intValue();
}
}
LivecoinOrderBook orderBook = getOrderBookRaw(currencyPair, depth, Boolean.TRUE);
return LivecoinAdapters.adaptOrderBook(orderBook, currencyPair);
} catch (LivecoinException e) {
throw LivecoinErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook in project XChange by knowm.
the class LivecoinAdapters method adaptToCurrencyPairKeysMap.
public static Map<CurrencyPair, LivecoinOrderBook> adaptToCurrencyPairKeysMap(LivecoinAllOrderBooks orderBooksRaw) {
Set<Map.Entry<String, LivecoinOrderBook>> entries = orderBooksRaw.getOrderBooksByPair().entrySet();
Map<CurrencyPair, LivecoinOrderBook> converted = new HashMap<>(entries.size());
for (Map.Entry<String, LivecoinOrderBook> entry : entries) {
String[] currencyPairSplit = entry.getKey().split("/");
CurrencyPair currencyPair = new CurrencyPair(currencyPairSplit[0], currencyPairSplit[1]);
converted.put(currencyPair, entry.getValue());
}
return converted;
}
use of org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook in project XChange by knowm.
the class MarketDataIntegration method allOrderBooksFetchTest.
@Test
public void allOrderBooksFetchTest() throws Exception {
Map<CurrencyPair, LivecoinOrderBook> orderBooksByPair = marketDataService.getAllOrderBooksRaw(10, true);
assertThat(orderBooksByPair).isNotNull().containsKeys(CurrencyPair.BTC_USD, CurrencyPair.ETH_BTC);
LivecoinOrderBook btcUsdOrderBook = orderBooksByPair.get(CurrencyPair.BTC_USD);
List<LivecoinOrder> btcUsdAsks = btcUsdOrderBook.getAsks();
assertThat(btcUsdAsks).isNotEmpty();
LivecoinOrder firstBtcUsdAsk = btcUsdAsks.get(0);
assertThat(firstBtcUsdAsk.getQuantity()).isNotNull().isPositive();
}
Aggregations