package org.knowm.xchange.examples.deribit.dto.marketdata;

import java.io.IOException;
import java.util.List;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.deribit.v2.dto.marketdata.*;
import org.knowm.xchange.deribit.v2.service.DeribitMarketDataService;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.examples.deribit.DeribitDemoUtils;
import org.knowm.xchange.service.marketdata.MarketDataService;

public class DeribitMarketdataDemo {

  public static void main(String[] args) throws IOException {

    Exchange exchange = DeribitDemoUtils.createExchange();
    generic(exchange);
    raw(exchange);
  }

  private static void generic(Exchange exchange) throws IOException {
    MarketDataService genericService = exchange.getMarketDataService();

    CurrencyPair pair = new CurrencyPair("BTC", "PERPETUAL");

    Ticker ticker = genericService.getTicker(pair);
    System.out.println(ticker);

    OrderBook orderBook = genericService.getOrderBook(pair);
    System.out.println(orderBook);

    Trades trades = genericService.getTrades(pair);
    System.out.println(trades);
  }

  private static void raw(Exchange exchange) throws IOException {
    DeribitMarketDataService service = (DeribitMarketDataService) exchange.getMarketDataService();

    String instrumentName = "BTC-PERPETUAL";
    String currency = "BTC";

    DeribitTicker ticker = service.getDeribitTicker(instrumentName);
    System.out.println(ticker);

    DeribitOrderBook orderBook = service.getDeribitOrderBook(instrumentName);
    System.out.println(orderBook);

    DeribitTrades trades = service.getDeribitLastTrades(instrumentName);
    System.out.println(trades);

    List<DeribitCurrency> currencies = service.getDeribitCurrencies();
    System.out.println(currencies);

    List<DeribitInstrument> instruments = service.getDeribitActiveInstruments(currency);
    System.out.println(instruments);

    List<DeribitSummary> summaries = service.getDeribitSummary(instrumentName);
    System.out.println(summaries);
  }
}

@@ -187,16 +187,62 @@
 cyPair;%0A
+import org.knowm.xchange.deribit.v2.dto.Kind;%0A
 import o
@@ -1722,32 +1722,38 @@
 k(instrumentName
+, null
 );%0A    System.ou
@@ -1813,23 +1813,16 @@
 vice.get
-Deribit
 LastTrad
@@ -1823,16 +1823,28 @@
 stTrades
+ByInstrument
 (instrum
@@ -1842,32 +1842,63 @@
 t(instrumentName
+,  null, null, null, null, null
 );%0A    System.ou
@@ -2089,14 +2089,8 @@
 ibit
-Active
 Inst
@@ -2105,16 +2105,36 @@
 currency
+, Kind.future, false
 );%0A    S
@@ -2214,30 +2214,35 @@
 vice.get
-Deribit
 Summary
+ByInstrument
 (instrum

Fix market data services examples