Search in sources :

Example 1 with LivecoinOrderBook

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);
    }
}
Also used : LivecoinException(org.knowm.xchange.livecoin.dto.LivecoinException) LivecoinOrderBook(org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook)

Example 2 with LivecoinOrderBook

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;
}
Also used : HashMap(java.util.HashMap) LivecoinOrderBook(org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook) HashMap(java.util.HashMap) Map(java.util.Map) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with LivecoinOrderBook

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();
}
Also used : LivecoinOrder(org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrder) LivecoinOrderBook(org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Aggregations

LivecoinOrderBook (org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrderBook)3 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 LivecoinException (org.knowm.xchange.livecoin.dto.LivecoinException)1 LivecoinOrder (org.knowm.xchange.livecoin.dto.marketdata.LivecoinOrder)1