content: package org.knowm.xchange.bitfinex.v1.service;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.List;
  import org.knowm.xchange.Exchange;
  import org.knowm.xchange.bitfinex.common.dto.BitfinexException;
  import org.knowm.xchange.bitfinex.v1.BitfinexAdapters;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLend;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendDepth;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexSymbolDetail;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker;
  import org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTrade;
  import org.knowm.xchange.currency.CurrencyPair;
  
  /**
   * Implementation of the market data service for Bitfinex
   *
   * <ul>
   *   <li>Provides access to various market data values
   * </ul>
   */
  public class BitfinexMarketDataServiceRaw extends BitfinexBaseService {
  
    /**
     * Constructor
     *
     * @param exchange
     */
    public BitfinexMarketDataServiceRaw(Exchange exchange) {
  
      super(exchange);
    }
  
    public BitfinexTicker getBitfinexTicker(String pair) throws IOException {
  
      try {
        BitfinexTicker bitfinexTicker = bitfinex.getTicker(pair);
        return bitfinexTicker;
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public BitfinexDepth getBitfinexOrderBook(String pair, Integer limitBids, Integer limitAsks)
        throws IOException {
  
      try {
        BitfinexDepth bitfinexDepth;
        if (limitBids == null && limitAsks == null) {
          bitfinexDepth = bitfinex.getBook(pair);
        } else {
          bitfinexDepth = bitfinex.getBook(pair, limitBids, limitAsks);
        }
        return bitfinexDepth;
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public BitfinexLendDepth getBitfinexLendBook(String currency, int limitBids, int limitAsks)
        throws IOException {
  
      try {
        BitfinexLendDepth bitfinexLendDepth = bitfinex.getLendBook(currency, limitBids, limitAsks);
        return bitfinexLendDepth;
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public BitfinexTrade[] getBitfinexTrades(String pair, long sinceTimestamp) throws IOException {
  
      try {
        BitfinexTrade[] bitfinexTrades = bitfinex.getTrades(pair, sinceTimestamp);
        return bitfinexTrades;
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public BitfinexLend[] getBitfinexLends(String currency, long sinceTimestamp, int limitTrades)
        throws IOException {
  
      try {
        BitfinexLend[] bitfinexLends = bitfinex.getLends(currency, sinceTimestamp, limitTrades);
        return bitfinexLends;
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public Collection<String> getBitfinexSymbols() throws IOException {
  
      try {
        return bitfinex.getSymbols();
      } catch (BitfinexException e) {
        throw handleException(e);
      }
    }
  
    public List<CurrencyPair> getExchangeSymbols() throws IOException {
  
      List<CurrencyPair> currencyPairs = new ArrayList<>();
      for (String symbol : bitfinex.getSymbols()) {
        currencyPairs.add(BitfinexAdapters.adaptCurrencyPair(symbol));
      }
      return currencyPairs;
    }
  
    public List<BitfinexSymbolDetail> getSymbolDetails() throws IOException {
      return bitfinex.getSymbolsDetails();
    }
  }
  