protected ExchangeException handleException(GeminiException e) { if (e.getMessage().contains("due to insufficient funds") || e.getMessage().contains("you do not have enough available")) return new FundsExceededException(e); return new ExchangeException(e); } }
protected ExchangeException handleError(Exception exception) { if (exception != null && exception.getMessage() != null) { 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 if (exception.getMessage().contains("The system is currently overloaded")) { return new SystemOverloadException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } return new ExchangeException(exception); }
public static ExchangeException adapt(BitfinexException e) { String message = e.getMessage(); if (StringUtils.isEmpty(message)) { return new ExchangeException(e); } if (message.toLowerCase().contains("unknown symbol")) { return new CurrencyPairNotValidException(message, e); } else if (message.toLowerCase().contains("not enough exchange balance")) { return new FundsExceededException(message, e); } else if (message.toUpperCase().contains("ERR_RATE_LIMIT")) { return new RateLimitExceededException(e); } else if (message.toLowerCase().contains("nonce")) { return new NonceException(e); } return new ExchangeException(message, 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); } } }
protected ExchangeException handleError(CoinbaseProException 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); } } }
private BigDecimal getPriceForMarketOrder(List<DVChainLevel> levels, MarketOrder marketOrder) { BigDecimal quantity = marketOrder.getOriginalAmount(); for (DVChainLevel level : levels) { if (quantity.compareTo(level.getMaxQuantity()) <= 0) { return marketOrder.getType() == Order.OrderType.BID ? level.getBuyPrice() : level.getSellPrice(); } } throw new FundsExceededException(); }
protected ExchangeException handleError(CryptonitException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected ExchangeException handleError(BitstampException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected <R> R checkResult(KrakenResult<R> krakenResult) { if (!krakenResult.isSuccess()) { String[] errors = krakenResult.getError(); if (errors.length == 0) { throw new ExchangeException("Missing error message"); } String error = errors[0]; if ("EAPI:Invalid nonce".equals(error)) { throw new NonceException(error); } else if ("EGeneral:Temporary lockout".equals(error)) { throw new FrequencyLimitExceededException(error); } else if ("EOrder:Insufficient funds".equals(error)) { throw new FundsExceededException(error); } if ("EAPI:Rate limit exceeded".equals(error)) { throw new RateLimitExceededException(error); } throw new ExchangeException(Arrays.toString(errors)); } return krakenResult.getResult(); }
private CryptonitWithdrawal checkAndReturnWithdrawal(CryptonitWithdrawal response) { try { if (response.hasError()) { if (response.toString().contains("You have only")) throw new FundsExceededException(response.toString()); else throw new ExchangeException( "Withdrawing funds from Cryptonit failed: " + response.toString()); } return response; } catch (CryptonitException e) { throw handleError(e); } }
protected void checkResult(WexReturn<?> result) { String error = result.getError(); if (!result.isSuccess()) { if (error != null) { if (error.startsWith(ERR_MSG_NONCE)) { throw new NonceException(error); } else if (error.startsWith(ERR_MSG_FUNDS)) { throw new FundsExceededException(error); } else if (error.equals("no transactions")) { return; // this isn't an error - just an indicator that there's no data } } throw new ExchangeException(error); } else if (result.getReturnValue() == null) { throw new ExchangeException("Didn't receive any return value. Message: " + error); } else if (error != null) { throw new ExchangeException(error); } } }
private BitstampWithdrawal checkAndReturnWithdrawal(BitstampWithdrawal response) { try { if (response.hasError()) { if (response.toString().contains("You have only")) { throw new FundsExceededException(response.toString()); } else { throw new ExchangeException( "Withdrawing funds from Bitstamp failed: " + response.toString()); } } return response; } catch (BitstampException e) { throw handleError(e); } }
protected ExchangeException handleError(Exception exception) { if (exception != null && exception.getMessage() != null) { 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 if (exception.getMessage().contains("The system is currently overloaded")) { return new SystemOverloadException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } return new ExchangeException(exception); }
protected ExchangeException handleException(GeminiException e) { if (e.getMessage().contains("due to insufficient funds") || e.getMessage().contains("you do not have enough available")) return new FundsExceededException(e); return new ExchangeException(e); } }
public static ExchangeException adapt(BitfinexException e) { String message = e.getMessage(); if (StringUtils.isEmpty(message)) { return new ExchangeException(e); } if (message.toLowerCase().contains("unknown symbol")) { return new CurrencyPairNotValidException(message, e); } else if (message.toLowerCase().contains("not enough exchange balance")) { return new FundsExceededException(message, e); } else if (message.toUpperCase().contains("ERR_RATE_LIMIT")) { return new RateLimitExceededException(e); } else if (message.toLowerCase().contains("nonce")) { return new NonceException(e); } return new ExchangeException(message, 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 ExchangeException handleError(GDAXException 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 ExchangeException handleError(BitstampException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
private BitstampWithdrawal checkAndReturnWithdrawal(BitstampWithdrawal response) { try { if (response.hasError()) { if (response.toString().contains("You have only")) { throw new FundsExceededException(response.toString()); } else { throw new ExchangeException( "Withdrawing funds from Bitstamp failed: " + response.toString()); } } return response; } catch (BitstampException e) { throw handleError(e); } }