Search in sources :

Example 6 with HttpStatusIOException

use of si.mazi.rescu.HttpStatusIOException in project XChange by knowm.

the class CmcMarketDataServiceRaw method getCmcLatestQuotes.

public Map<String, CmcTicker> getCmcLatestQuotes(Set<Currency> baseCurrencySet, Set<Currency> convertCurrencySet) throws IOException {
    List<String> baseSymbols = baseCurrencySet.stream().map(c -> c.getCurrencyCode()).collect(Collectors.toList());
    String commaSeparatedBaseSymbols = StringUtils.join(baseSymbols, ",");
    List<String> convertSymbols = convertCurrencySet.stream().map(c -> c.getCurrencyCode()).collect(Collectors.toList());
    String commaSeparatedConvertCurrencies = StringUtils.join(convertSymbols, ",");
    CmcTickerResponse response = null;
    try {
        response = cmcAuthenticated.getLatestQuotes(apiKey, commaSeparatedBaseSymbols, commaSeparatedConvertCurrencies);
    } catch (HttpStatusIOException ex) {
        CmcErrorAdapter.adapt(ex);
    }
    return response.getData();
}
Also used : CmcCurrencyInfoResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse) CmcTickerResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcTickerResponse) Set(java.util.Set) IOException(java.io.IOException) CmcErrorAdapter(org.knowm.xchange.coinmarketcap.pro.v1.CmcErrorAdapter) CmcCurrencyMapResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyMapResponse) Exchange(org.knowm.xchange.Exchange) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) CmcCurrency(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrency) CmcCurrencyInfo(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrencyInfo) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) CmcTicker(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker) CmcTickerListResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcTickerListResponse) Map(java.util.Map) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException) CmcTickerResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcTickerResponse) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Example 7 with HttpStatusIOException

use of si.mazi.rescu.HttpStatusIOException in project XChange by knowm.

the class CmcMarketDataServiceRaw method getCmcMultipleCurrencyInfo.

public Map<String, CmcCurrencyInfo> getCmcMultipleCurrencyInfo(List<Currency> currencyList) throws IOException {
    List<String> currencyCodes = currencyList.stream().map(Currency::getCurrencyCode).collect(Collectors.toList());
    String commaSeparatedCurrencyCodes = StringUtils.join(currencyCodes, ",");
    CmcCurrencyInfoResponse response = null;
    try {
        response = cmcAuthenticated.getCurrencyInfo(apiKey, commaSeparatedCurrencyCodes);
    } catch (HttpStatusIOException ex) {
        CmcErrorAdapter.adapt(ex);
    }
    return response.getData();
}
Also used : CmcCurrencyInfoResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Example 8 with HttpStatusIOException

use of si.mazi.rescu.HttpStatusIOException in project XChange by knowm.

the class CmcMarketDataServiceRaw method getCmcCurrencyInfo.

public CmcCurrencyInfo getCmcCurrencyInfo(Currency currency) throws IOException {
    String currencyCode = currency.getCurrencyCode();
    CmcCurrencyInfoResponse response = null;
    try {
        response = cmcAuthenticated.getCurrencyInfo(apiKey, currencyCode);
    } catch (HttpStatusIOException ex) {
        CmcErrorAdapter.adapt(ex);
    }
    return response.getData().get(currencyCode);
}
Also used : CmcCurrencyInfoResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Example 9 with HttpStatusIOException

use of si.mazi.rescu.HttpStatusIOException in project XChange by knowm.

the class QuoineTradeServiceRaw method placeMarketOrder.

public QuoineOrderResponse placeMarketOrder(CurrencyPair currencyPair, String type, BigDecimal originalAmount) throws IOException {
    int productId = productId(currencyPair);
    QuoineNewOrderRequest quoineNewOrderRequest = useMargin ? new QuoineNewMarginOrderRequest("market", productId, type, originalAmount, null, leverageLevel, currencyPair.counter.getCurrencyCode()) : new QuoineNewOrderRequest("market", productId, type, originalAmount, null);
    try {
        return quoine.placeOrder(QUOINE_API_VERSION, signatureCreator, contentType, new QuoineNewOrderRequestWrapper(quoineNewOrderRequest));
    } catch (HttpStatusIOException e) {
        throw handleHttpError(e);
    }
}
Also used : QuoineNewMarginOrderRequest(org.knowm.xchange.quoine.dto.trade.QuoineNewMarginOrderRequest) QuoineNewOrderRequestWrapper(org.knowm.xchange.quoine.dto.trade.QuoineNewOrderRequestWrapper) QuoineNewOrderRequest(org.knowm.xchange.quoine.dto.trade.QuoineNewOrderRequest) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Aggregations

HttpStatusIOException (si.mazi.rescu.HttpStatusIOException)9 CmcCurrencyInfoResponse (org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse)3 Currency (org.knowm.xchange.currency.Currency)3 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)3 IOException (java.io.IOException)2 QuoineNewMarginOrderRequest (org.knowm.xchange.quoine.dto.trade.QuoineNewMarginOrderRequest)2 QuoineNewOrderRequest (org.knowm.xchange.quoine.dto.trade.QuoineNewOrderRequest)2 QuoineNewOrderRequestWrapper (org.knowm.xchange.quoine.dto.trade.QuoineNewOrderRequestWrapper)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Exchange (org.knowm.xchange.Exchange)1 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)1 CmcErrorAdapter (org.knowm.xchange.coinmarketcap.pro.v1.CmcErrorAdapter)1 CmcResult (org.knowm.xchange.coinmarketcap.pro.v1.dto.CmcResult)1 CmcCurrency (org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrency)1