package org.knowm.xchange.okcoin.v3.service;

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.okcoin.OkexAdaptersV3;
import org.knowm.xchange.okcoin.OkexExchangeV3;
import org.knowm.xchange.okcoin.v3.dto.marketdata.OkexSpotTicker;
import org.knowm.xchange.service.marketdata.MarketDataService;
import org.knowm.xchange.service.marketdata.params.Params;

public class OkexMarketDataService extends OkexMarketDataServiceRaw implements MarketDataService {

  public OkexMarketDataService(OkexExchangeV3 exchange) {
    super(exchange);
  }

  @Override
  public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {
    OkexSpotTicker tokenPairInformation =
        okex.getSpotTicker(OkexAdaptersV3.toSpotInstrument(currencyPair));
    return OkexAdaptersV3.convert(tokenPairInformation);
  }

  @Override
  public List<Ticker> getTickers(Params params) throws IOException {
    return okex.getAllSpotTickers().stream()
        .map(OkexAdaptersV3::convert)
        .collect(Collectors.toList());
  }
}

@@ -174,16 +174,67 @@
 cyPair;%0A
+import org.knowm.xchange.dto.marketdata.OrderBook;%0A
 import o
@@ -365,24 +365,89 @@
 ExchangeV3;%0A
+import org.knowm.xchange.okcoin.v3.dto.marketdata.OkexOrderBook;%0A
 import org.k
@@ -1294,11 +1294,577 @@
 ());%0A  %7D
+%0A%0A  @Override%0A  public OrderBook getOrderBook(CurrencyPair pair, Object... args) throws IOException %7B%0A%0A    int limitDepth = 50;%0A%0A    if (args != null && args.length == 1) %7B%0A      Object arg0 = args%5B0%5D;%0A      if (!(arg0 instanceof Integer)) %7B%0A        throw new IllegalArgumentException(%22Argument 0 must be an Integer!%22);%0A      %7D else %7B%0A        limitDepth = (Integer) arg0;%0A      %7D%0A    %7D%0A    OkexOrderBook okexOrderbook =%0A        okex.getOrderBook(OkexAdaptersV3.toSpotInstrument(pair), limitDepth);%0A    return OkexAdaptersV3.convertOrderBook(okexOrderbook, pair);%0A  %7D
 %0A%7D%0A

Order Book and Order Details implementation