public static Date parseDate(final String date) { try { return DATE_FORMAT.parse(date); } catch (final ParseException e) { throw new ExchangeException("Illegal date/time format: " + date, e); } } }
public static Date parseDate(final String date) { try { SimpleDateFormat threadSafeClone = (SimpleDateFormat) DATE_FORMAT.clone(); return threadSafeClone.parse(date); } catch (final ParseException e) { throw new ExchangeException("Illegal date/time format: " + date, e); } }
public List<WithdrawRecord> withdrawalHistory() throws IOException { BleutradeResponse<List<WithdrawRecord>> response = bleutrade.withdrawHistory(apiKey, signatureCreator, exchange.getNonceFactory()); if (!response.success) { throw new ExchangeException(response.message); } return response.result; } }
@Override public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { if (orderParams instanceof CancelOrderByIdParams) { return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId()); } throw new ExchangeException("You need to provide the the order id to cancel an order."); }
protected RuntimeException handleError(BitcoindeException exception) { if (exception.getMessage().contains("Insufficient credits")) { return new RateLimitExceededException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } }
public BleutradeBalance getBleutradeBalance(String currency) throws IOException { try { BleutradeBalanceReturn response = bleutrade.getBalance(apiKey, signatureCreator, exchange.getNonceFactory(), currency); if (!response.getSuccess()) { throw new ExchangeException(response.getMessage()); } return response.getResult(); } catch (BleutradeException e) { throw new ExchangeException(e); } }
protected ExchangeException handleError(BitflyerException exception) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected RuntimeException handleError(ANXException exception) { if ("Insufficient Funds".equals(exception.getError())) { return new FundsExceededException(exception.getError(), exception); } else { return new ExchangeException(exception.getError(), exception); } } }
public CryptoFacilitiesTickers getCryptoFacilitiesTickers() throws IOException { CryptoFacilitiesTickers tickers = cryptoFacilities.getTickers(); if (tickers.isSuccess()) { return tickers; } else { throw new ExchangeException("Error getting CF tickers: " + tickers.getError()); } }
public CobinhoodResponse<CobinhoodCurrencies> getCobinhoodCurrencies() throws IOException { try { return checkSuccess(cobinhood.currencies()); } catch (CobinhoodException e) { throw new ExchangeException(e.getMessage(), e); } }
@Override public String withdrawFunds(Currency currency, BigDecimal amount, String address) throws IOException { CampBXResponse campBXResponse = withdrawCampBXFunds(amount, address); logger.debug("campBXResponse = {}", campBXResponse); if (!campBXResponse.isError()) { return campBXResponse.getSuccess(); } else { throw new ExchangeException("Error calling withdrawFunds(): " + campBXResponse.getError()); } }
public void cancelBiboxOrder(String orderId) { try { BiboxCancelTradeCommand cmd = new BiboxCancelTradeCommand(new BigInteger(orderId)); BiboxSingleResponse<String> response = bibox.cancelTrade(BiboxCommands.of(cmd).json(), apiKey, signatureCreator); throwErrors(response); } catch (BiboxException e) { throw new ExchangeException(e.getMessage()); } }
public BitMarketAccountInfoResponse getBitMarketAccountInfo() throws IOException, ExchangeException { BitMarketAccountInfoResponse response = bitMarketAuthenticated.info(apiKey, sign, exchange.getNonceFactory()); if (!response.getSuccess()) { throw new ExchangeException( String.format("%d: %s", response.getError(), response.getErrorMsg())); } return response; }
public BitMarketOrdersResponse getBitMarketOpenOrders() throws IOException, ExchangeException { BitMarketOrdersResponse response = bitMarketAuthenticated.orders(apiKey, sign, exchange.getNonceFactory()); if (!response.getSuccess()) { throw new ExchangeException( String.format("%d: %s", response.getError(), response.getErrorMsg())); } return response; }
public List<BiboxMarket> getAllBiboxMarkets() throws IOException { try { BiboxResponse<List<BiboxMarket>> response = bibox.marketAll(ALL_TICKERS_CMD); throwErrors(response); return response.getResult(); } catch (BiboxException e) { throw new ExchangeException(e.getMessage()); } }
@Override public String placeLimitOrder(LimitOrder limitOrder) throws IOException { CampBXResponse campBXResponse = placeCampBXLimitOrder(limitOrder); logger.debug("campBXResponse = {}", campBXResponse); if (!campBXResponse.isError()) { return composeOrderId(campBXResponse.getSuccess(), limitOrder.getType()); } else { throw new ExchangeException("Error calling placeLimitOrder(): " + campBXResponse.getError()); } }
public List<CCEXOpenorder> getCCEXOpenOrders() throws IOException { CCEXGetopenordersResponse response = cCEXAuthenticated.getopenorders(apiKey, signatureCreator, exchange.getNonceFactory()); if (response.isSuccess()) { return response.getResult(); } else { throw new ExchangeException(response.getMessage()); } }
public CoinfloorOrder[] getOpenOrders(CurrencyPair pair) throws IOException { try { return coinfloor.getOpenOrders(normalise(pair.base), normalise(pair.counter)); } catch (HttpStatusIOException e) { if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) { throw new ExchangeException(e.getHttpBody(), e); } else { throw e; } } }
public BiboxTicker getBiboxTicker(CurrencyPair currencyPair) throws IOException { try { BiboxResponse<BiboxTicker> response = bibox.mdata(TICKER_CMD, toBiboxPair(currencyPair)); throwErrors(response); return response.getResult(); } catch (BiboxException e) { throw new ExchangeException(e.getMessage()); } }
public List<BiboxCoin> getBiboxAccountInfo() { try { BiboxSingleResponse<List<BiboxCoin>> response = bibox.coinList(COIN_LIST_CMD.json(), apiKey, signatureCreator); throwErrors(response); return response.get().getResult(); } catch (BiboxException e) { throw new ExchangeException(e.getMessage()); } }