Search in sources :

Example 1 with PoloniexDepth

use of org.knowm.xchange.poloniex.dto.marketdata.PoloniexDepth in project XChange by knowm.

the class PoloniexMarketDataService method getOrderBook.

@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws ExchangeException, IOException {
    try {
        PoloniexDepth depth = null;
        // ~full order book
        int depthLimit = 999999;
        if (args != null && args.length > 0) {
            if (args[0] instanceof Integer) {
                depthLimit = (Integer) args[0];
            } else {
                throw new ExchangeException("Orderbook size argument must be an Integer!");
            }
        }
        depth = getPoloniexDepth(currencyPair, depthLimit);
        if (depth == null) {
            depth = getPoloniexDepth(currencyPair);
        }
        return PoloniexAdapters.adaptPoloniexDepth(depth, currencyPair);
    } catch (PoloniexException e) {
        throw PoloniexErrorAdapter.adapt(e);
    }
}
Also used : ExchangeException(org.knowm.xchange.exceptions.ExchangeException) PoloniexDepth(org.knowm.xchange.poloniex.dto.marketdata.PoloniexDepth) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException)

Example 2 with PoloniexDepth

use of org.knowm.xchange.poloniex.dto.marketdata.PoloniexDepth in project XChange by knowm.

the class PoloniexOrderbook method toPoloniexDepth.

public PoloniexDepth toPoloniexDepth() {
    PoloniexDepth orderbook = new PoloniexDepth();
    List<List<BigDecimal>> poloniexDepthAsk = toPoloniexDepthLevels(asks);
    List<List<BigDecimal>> poloniexDepthBid = toPoloniexDepthLevels(bids);
    orderbook.setAsks(poloniexDepthAsk);
    orderbook.setBids(poloniexDepthBid);
    return orderbook;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) PoloniexDepth(org.knowm.xchange.poloniex.dto.marketdata.PoloniexDepth)

Aggregations

PoloniexDepth (org.knowm.xchange.poloniex.dto.marketdata.PoloniexDepth)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 PoloniexException (org.knowm.xchange.poloniex.dto.PoloniexException)1