use of org.knowm.xchange.deribit.v2.dto.marketdata.DeribitInstrument in project XChange by knowm.
the class DeribitMarketdataDemo method raw.
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, null);
System.out.println(orderBook);
DeribitTrades trades = service.getLastTradesByInstrument(instrumentName, null, null, null, null, null);
System.out.println(trades);
List<DeribitCurrency> currencies = service.getDeribitCurrencies();
System.out.println(currencies);
List<DeribitInstrument> instruments = service.getDeribitInstruments(currency, Kind.future, false);
System.out.println(instruments);
List<DeribitSummary> summaries = service.getSummaryByInstrument(instrumentName);
System.out.println(summaries);
}
use of org.knowm.xchange.deribit.v2.dto.marketdata.DeribitInstrument in project XChange by knowm.
the class DeribitAdapters method adaptInstrument.
public static Instrument adaptInstrument(String instrumentName) {
String[] parts = instrumentName.split("-");
if (parts.length == 2) {
DeribitInstrument future = new DeribitInstrument();
future.setBaseCurrency(parts[0]);
future.setQuoteCurrency(IMPLIED_COUNTER);
if (PERPETUAL.equalsIgnoreCase(parts[1])) {
future.setSettlementPeriod(PERPETUAL);
} else {
try {
future.setExpirationTimestamp(parseDate(parts[1]).getTime());
} catch (ParseException e) {
throw new IllegalArgumentException("Could not adapt instrument from name '" + instrumentName + "'");
}
}
return adaptFuturesContract(future);
} else if (parts.length >= 3 && PERPETUAL.equalsIgnoreCase(parts[2])) {
DeribitInstrument future = new DeribitInstrument();
future.setBaseCurrency(parts[0]);
future.setQuoteCurrency(parts[1]);
future.setSettlementPeriod(PERPETUAL);
return adaptFuturesContract(future);
} else if (parts.length == 4) {
DeribitInstrument option = new DeribitInstrument();
option.setBaseCurrency(parts[0]);
try {
option.setExpirationTimestamp(parseDate(parts[1]).getTime());
} catch (ParseException e) {
throw new IllegalArgumentException("Could not adapt instrument from name '" + instrumentName + "'");
}
option.setInstrumentName(instrumentName);
return adaptOptionsContract(option);
}
throw new IllegalArgumentException("Could not adapt instrument from name '" + instrumentName + "'");
}
use of org.knowm.xchange.deribit.v2.dto.marketdata.DeribitInstrument in project XChange by knowm.
the class DeribitExchange method updateExchangeMetaData.
public void updateExchangeMetaData() throws IOException {
Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies();
Map<FuturesContract, DerivativeMetaData> futures = exchangeMetaData.getFutures();
Map<OptionsContract, DerivativeMetaData> options = exchangeMetaData.getOptions();
List<DeribitCurrency> activeDeribitCurrencies = ((DeribitMarketDataServiceRaw) marketDataService).getDeribitCurrencies();
currencies.clear();
futures.clear();
options.clear();
for (DeribitCurrency deribitCurrency : activeDeribitCurrencies) {
currencies.put(new Currency(deribitCurrency.getCurrency()), DeribitAdapters.adaptMeta(deribitCurrency));
List<DeribitInstrument> deribitInstruments = ((DeribitMarketDataServiceRaw) marketDataService).getDeribitInstruments(deribitCurrency.getCurrency(), null, null);
for (DeribitInstrument deribitInstrument : deribitInstruments) {
if (deribitInstrument.getKind() == Kind.future) {
futures.put(DeribitAdapters.adaptFuturesContract(deribitInstrument), DeribitAdapters.adaptMeta(deribitInstrument));
} else {
options.put(DeribitAdapters.adaptOptionsContract(deribitInstrument), DeribitAdapters.adaptMeta(deribitInstrument));
}
}
}
}
Aggregations