Search in sources :

Example 1 with LatokenOrderbook

use of org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook in project XChange by knowm.

the class LatokenAdapters method adaptOrderBook.

public static OrderBook adaptOrderBook(Exchange exchange, LatokenOrderbook latokenOrderbook) {
    CurrencyPair pair = adaptCurrencyPair(exchange, latokenOrderbook.getSymbol());
    List<LimitOrder> asks = latokenOrderbook.getAsks().stream().map(level -> new LimitOrder.Builder(OrderType.ASK, pair).originalAmount(level.getAmount()).limitPrice(level.getPrice()).build()).collect(Collectors.toList());
    List<LimitOrder> bids = latokenOrderbook.getBids().stream().map(level -> new LimitOrder.Builder(OrderType.BID, pair).originalAmount(level.getAmount()).limitPrice(level.getPrice()).build()).collect(Collectors.toList());
    return new OrderBook(null, asks, bids);
}
Also used : LatokenOrderbook(org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook) OrderType(org.knowm.xchange.dto.Order.OrderType) LatokenBalance(org.knowm.xchange.latoken.dto.account.LatokenBalance) LatokenUserTrade(org.knowm.xchange.latoken.dto.trade.LatokenUserTrade) Exchange(org.knowm.xchange.Exchange) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) Balance(org.knowm.xchange.dto.account.Balance) TradeSortType(org.knowm.xchange.dto.marketdata.Trades.TradeSortType) BigDecimal(java.math.BigDecimal) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) LatokenCurrency(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenCurrency) LatokenTrades(org.knowm.xchange.latoken.dto.marketdata.LatokenTrades) LatokenPair(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenPair) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) RoundingMode(java.math.RoundingMode) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OrderStatus(org.knowm.xchange.dto.Order.OrderStatus) Ticker(org.knowm.xchange.dto.marketdata.Ticker) LatokenOrder(org.knowm.xchange.latoken.dto.trade.LatokenOrder) LatokenOrderSide(org.knowm.xchange.latoken.dto.trade.LatokenOrderSide) UserTrades(org.knowm.xchange.dto.trade.UserTrades) UserTrade(org.knowm.xchange.dto.trade.UserTrade) LatokenOrderStatus(org.knowm.xchange.latoken.dto.trade.LatokenOrderStatus) LatokenTicker(org.knowm.xchange.latoken.dto.marketdata.LatokenTicker) Collectors(java.util.stream.Collectors) Trades(org.knowm.xchange.dto.marketdata.Trades) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) LatokenTrade(org.knowm.xchange.latoken.dto.marketdata.LatokenTrade) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) Optional(java.util.Optional) Trade(org.knowm.xchange.dto.marketdata.Trade) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) LatokenUserTrades(org.knowm.xchange.latoken.dto.trade.LatokenUserTrades) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with LatokenOrderbook

use of org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook in project XChange by knowm.

the class LatokenMarketDataService method getOrderBook.

@Override
public OrderBook getOrderBook(CurrencyPair pair, Object... args) throws IOException {
    try {
        int depthLimit = maxOrderbookDepth;
        if (args != null && args.length == 1) {
            Object arg0 = args[0];
            if (!(arg0 instanceof Integer)) {
                throw new ExchangeException("Depth-limit must be an Integer!");
            } else {
                depthLimit = (Integer) arg0;
            }
        }
        LatokenOrderbook latokenOrderbook = getLatokenOrderbook(pair, depthLimit);
        return LatokenAdapters.adaptOrderBook(this.exchange, latokenOrderbook);
    } catch (LatokenException e) {
        throw LatokenErrorAdapter.adapt(e);
    }
}
Also used : LatokenException(org.knowm.xchange.latoken.dto.LatokenException) LatokenOrderbook(org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Aggregations

ExchangeException (org.knowm.xchange.exceptions.ExchangeException)2 LatokenOrderbook (org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook)2 BigDecimal (java.math.BigDecimal)1 RoundingMode (java.math.RoundingMode)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Exchange (org.knowm.xchange.Exchange)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 OrderStatus (org.knowm.xchange.dto.Order.OrderStatus)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 Balance (org.knowm.xchange.dto.account.Balance)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1 Ticker (org.knowm.xchange.dto.marketdata.Ticker)1 Trade (org.knowm.xchange.dto.marketdata.Trade)1 Trades (org.knowm.xchange.dto.marketdata.Trades)1 TradeSortType (org.knowm.xchange.dto.marketdata.Trades.TradeSortType)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1