org.knowm.xchange.cobinhood.service.CobinhoodMarketDataServiceRaw Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xchange-cobinhood Show documentation
Show all versions of xchange-cobinhood Show documentation
Development fork. Not for general use.
package org.knowm.xchange.cobinhood.service;
import java.io.IOException;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.cobinhood.CobinhoodException;
import org.knowm.xchange.cobinhood.dto.CobinhoodAdapters;
import org.knowm.xchange.cobinhood.dto.CobinhoodResponse;
import org.knowm.xchange.cobinhood.dto.marketdata.*;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.exceptions.ExchangeException;
public class CobinhoodMarketDataServiceRaw extends CobinhoodBaseService {
protected CobinhoodMarketDataServiceRaw(Exchange exchange) {
super(exchange);
}
public CobinhoodResponse getCobinhoodTicker(CurrencyPair currencyPair)
throws IOException {
try {
return checkSuccess(cobinhood.tick(CobinhoodAdapters.adaptCurrencyPair(currencyPair)));
} catch (CobinhoodException e) {
throw new ExchangeException(e.getMessage(), e);
}
}
public CobinhoodResponse getCobinhoodTickers() throws IOException {
try {
return checkSuccess(cobinhood.tick());
} catch (CobinhoodException e) {
throw new ExchangeException(e.getMessage(), e);
}
}
public CobinhoodResponse getCobinhoodOrderBook(
CurrencyPair currencyPair) throws IOException {
return getCobinhoodOrderBook(currencyPair, null);
}
public CobinhoodResponse getCobinhoodOrderBook(
CurrencyPair currencyPair, Integer limit) throws IOException {
try {
return checkSuccess(
cobinhood.orders(CobinhoodAdapters.adaptCurrencyPair(currencyPair), limit));
} catch (CobinhoodException e) {
throw new ExchangeException(e.getMessage(), e);
}
}
public CobinhoodResponse getCobinhoodTrades(
CurrencyPair currencyPair, Integer limit) throws IOException {
try {
return checkSuccess(
cobinhood.trades(CobinhoodAdapters.adaptCurrencyPair(currencyPair), limit));
} catch (CobinhoodException e) {
throw new ExchangeException(e.getMessage(), e);
}
}
public CobinhoodResponse getCobinhoodCurrencies() throws IOException {
try {
return checkSuccess(cobinhood.currencies());
} catch (CobinhoodException e) {
throw new ExchangeException(e.getMessage(), e);
}
}
public static CobinhoodResponse checkSuccess(CobinhoodResponse response) {
if (response.isSuccess()) {
return response;
} else {
throw new ExchangeException(response.getError().getCode());
}
}
}