Search in sources :

Example 1 with BitfinexLendDepth

use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth in project XChange by knowm.

the class LendDepthDemo method raw.

private static void raw(BitfinexMarketDataServiceRaw marketDataService) throws IOException {
    // Get the latest order book data for USD swaps
    BitfinexLendDepth bitfinexDepth = marketDataService.getBitfinexLendBook("USD", 50, 50);
    System.out.println("Current Order Book size for USD: " + (bitfinexDepth.getAsks().length + bitfinexDepth.getBids().length));
    System.out.println("First Ask: " + bitfinexDepth.getAsks()[0].toString());
    System.out.println("First Bid: " + bitfinexDepth.getBids()[0].toString());
    System.out.println(bitfinexDepth.toString());
}
Also used : BitfinexLendDepth(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth)

Example 2 with BitfinexLendDepth

use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth in project XChange by knowm.

the class BitfinexMarketDataService method getLendOrderBook.

public LoanOrderBook getLendOrderBook(String currency, Object... args) throws IOException {
    try {
        // According to API docs, default is 50
        int limitBids = 50;
        int limitAsks = 50;
        if (args != null && args.length == 2) {
            Object arg0 = args[0];
            if (!(arg0 instanceof Integer)) {
                throw new ExchangeException("Argument 0 must be an Integer!");
            } else {
                limitBids = (Integer) arg0;
            }
            Object arg1 = args[1];
            if (!(arg1 instanceof Integer)) {
                throw new ExchangeException("Argument 1 must be an Integer!");
            } else {
                limitAsks = (Integer) arg1;
            }
        }
        BitfinexLendDepth bitfinexLendDepth = getBitfinexLendBook(currency, limitBids, limitAsks);
        List<FixedRateLoanOrder> fixedRateAsks = BitfinexAdapters.adaptFixedRateLoanOrders(bitfinexLendDepth.getAsks(), currency, "ask", "");
        List<FixedRateLoanOrder> fixedRateBids = BitfinexAdapters.adaptFixedRateLoanOrders(bitfinexLendDepth.getBids(), currency, "bid", "");
        List<FloatingRateLoanOrder> floatingRateAsks = BitfinexAdapters.adaptFloatingRateLoanOrders(bitfinexLendDepth.getAsks(), currency, "ask", "");
        List<FloatingRateLoanOrder> floatingRateBids = BitfinexAdapters.adaptFloatingRateLoanOrders(bitfinexLendDepth.getBids(), currency, "bid", "");
        return new LoanOrderBook(null, fixedRateAsks, fixedRateBids, floatingRateAsks, floatingRateBids);
    } catch (BitfinexException e) {
        throw BitfinexErrorAdapter.adapt(e);
    }
}
Also used : LoanOrderBook(org.knowm.xchange.dto.marketdata.LoanOrderBook) FixedRateLoanOrder(org.knowm.xchange.dto.trade.FixedRateLoanOrder) BitfinexLendDepth(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BitfinexException(org.knowm.xchange.bitfinex.dto.BitfinexException) FloatingRateLoanOrder(org.knowm.xchange.dto.trade.FloatingRateLoanOrder)

Aggregations

BitfinexLendDepth (org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth)2 BitfinexException (org.knowm.xchange.bitfinex.dto.BitfinexException)1 LoanOrderBook (org.knowm.xchange.dto.marketdata.LoanOrderBook)1 FixedRateLoanOrder (org.knowm.xchange.dto.trade.FixedRateLoanOrder)1 FloatingRateLoanOrder (org.knowm.xchange.dto.trade.FloatingRateLoanOrder)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1