public Map<String, Object> adaptTradeVolume(String data) { Map<String, Object> resultMap = new HashMap<String, Object>(); CoinfloorTradeVolume rawRetObj; try { rawRetObj = streamObjectMapper.readValue(data, CoinfloorTradeVolume.class); } catch (IOException e) { throw new ExchangeException("JSON parse error", e); } resultMap.put("generic", rawRetObj.getAssetVol()); resultMap.put("raw", rawRetObj); return resultMap; }
protected <R extends CryptoTradeBaseResponse> R handleResponse(R response) { final String status = response.getStatus(); final String error = response.getError(); if ((status != null && status.equalsIgnoreCase("error")) || (error != null && !error.isEmpty())) { throw new ExchangeException(error); } return response; }
public BitfinexLend[] getBitfinexLends(String currency, long sinceTimestamp, int limitTrades) throws IOException { try { BitfinexLend[] bitfinexLends = bitfinex.getLends(currency, sinceTimestamp, limitTrades); return bitfinexLends; } catch (BitfinexException e) { throw new ExchangeException("Bitfinex returned an error: " + e.getMessage()); } }
public BitstampTransaction[] getBitstampTransactions(Object... args) throws IOException { BitstampTransaction[] transactions = null; if (args.length == 0) { transactions = bitstamp.getTransactions(); // default values: offset=0, limit=100 } else if (args.length == 1) { BitstampTime bitstampTime = (BitstampTime) args[0]; transactions = bitstamp.getTransactions(bitstampTime.toString().toLowerCase()); // default values: limit=100 } else { throw new ExchangeException("Invalid argument length. Must be 0, or 1."); } return transactions; }
public BleutradeDepositAddress getBleutradeDepositAddress(String currency) throws IOException { try { BleutradeDepositAddressReturn response = bleutrade.getDepositAddress(apiKey, signatureCreator, exchange.getNonceFactory(), currency); if (!response.getSuccess()) { throw new ExchangeException(response.getMessage()); } return response.getResult(); } catch (BleutradeException e) { throw new ExchangeException(e.getMessage()); } }
public PoloniexPublicTrade[] getPoloniexPublicTrades(CurrencyPair currencyPair) throws IOException { String command = "returnTradeHistory"; String pairString = PoloniexUtils.toPairString(currencyPair); try { PoloniexPublicTrade[] trades = poloniex.getTrades(command, pairString, null, null); return trades; } catch (PoloniexException e) { throw new ExchangeException(e.getError()); } }
public String withdrawBitsoFunds(BigDecimal amount, final String address) throws IOException { final String response = bitsoAuthenticated.withdrawBitcoin(exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory(), amount, address); if (!"ok".equals(response)) { throw new ExchangeException("Withdrawing funds from Bitso failed: " + response); } return response; }
public BitfinexOrderStatusResponse getBitfinexOrderStatus(String orderId) throws IOException { try { BitfinexOrderStatusResponse orderStatus = bitfinex.orderStatus(apiKey, payloadCreator, signatureCreator, new BitfinexOrderStatusRequest(String.valueOf(exchange.getNonceFactory().createValue()), Integer.valueOf(orderId))); return orderStatus; } catch (BitfinexException e) { throw new ExchangeException(e.getMessage()); } }
public BitfinexOfferStatusResponse getBitfinexOfferStatusResponse(String offerId) throws IOException { try { BitfinexOfferStatusResponse offerStatus = bitfinex.offerStatus(apiKey, payloadCreator, signatureCreator, new BitfinexOfferStatusRequest(String.valueOf(exchange.getNonceFactory().createValue()), Integer.valueOf(offerId))); return offerStatus; } catch (BitfinexException e) { throw new ExchangeException(e.getMessage()); } }
protected static <T extends OkCoinErrorResult> T returnOrThrow(T t) { if (t.isResult()) { return t; } else { throw new ExchangeException(OkCoinUtils.getErrorMessage(t.getErrorCode())); } } }
public BleutradeTicker getBleutradeTicker(CurrencyPair currencyPair) throws IOException { String pairString = BleutradeUtils.toPairString(currencyPair); BleutradeTickerReturn response = bleutrade.getBleutradeTicker(pairString); if (!response.getSuccess()) { throw new ExchangeException(response.getMessage()); } return response.getResult().get(0); }
public BitfinexCreditResponse[] getBitfinexActiveCredits() throws IOException { try { BitfinexCreditResponse[] credits = bitfinex.activeCredits(apiKey, payloadCreator, signatureCreator, new BitfinexActiveCreditsRequest(String.valueOf(exchange.getNonceFactory().createValue()))); return credits; } catch (BitfinexException e) { throw new ExchangeException(e.getMessage()); } }
public BittrexTrade[] getBittrexTrades(String pair, int count) throws IOException { BittrexTradesResponse response = bittrexAuthenticated.getTrades(pair, count); if (response.getSuccess()) { BittrexTrade[] bittrexTrades = response.getTrades(); return bittrexTrades; } else { throw new ExchangeException(response.getMessage()); } } }
public boolean cancelBittrexLimitOrder(String uuid) throws IOException { BittrexCancelOrderResponse response = bittrexAuthenticated.cancel(apiKey, signatureCreator, exchange.getNonceFactory(), uuid); if (response.getSuccess()) { return true; } else { throw new ExchangeException(response.getMessage()); } }
public ArrayList<BittrexTicker> getBittrexTickers() throws IOException { BittrexTickersResponse response = bittrexAuthenticated.getTickers(); if (response.isSuccess()) { return response.getTickers(); } else { throw new ExchangeException(response.getMessage()); } }
public BitfinexOfferStatusResponse placeBitfinexFloatingRateLoanOrder(FloatingRateLoanOrder loanOrder, BitfinexOrderType orderType) throws IOException { String direction = loanOrder.getType() == OrderType.BID ? "loan" : "lend"; try { BitfinexOfferStatusResponse newOrderResponse = bitfinex.newOffer(apiKey, payloadCreator, signatureCreator, new BitfinexNewOfferRequest(String.valueOf(exchange.getNonceFactory().createValue()), loanOrder.getCurrency(), loanOrder.getTradableAmount(), new BigDecimal("0.0"), loanOrder.getDayPeriod(), direction)); return newOrderResponse; } catch (BitfinexException e) { throw new ExchangeException(e.getMessage()); } }
public CexIOBalanceInfo getCexIOAccountInfo() throws IOException { CexIOBalanceInfo info = cexIOAuthenticated.getBalance(exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); if (info.getError() != null) { throw new ExchangeException("Error getting balance. " + info.getError()); } return info; }
public String getBittrexDepositAddress(String currency) throws IOException { BittrexDepositAddressResponse response = bittrexAuthenticated.getdepositaddress(apiKey, signatureCreator, exchange.getNonceFactory(), currency); if (response.getSuccess()) { return response.getResult().getAddress(); } else { throw new ExchangeException(response.getMessage()); } }
public BitcoinToYouBaseTradeApiResult<BitcoinToYouBalance[]> getBitcoinToYouBalance() throws IOException { Long nonce = exchange.getNonceFactory().createValue(); BitcoinToYouDigest signatureCreator = BitcoinToYouDigest.createInstance(exchange.getExchangeSpecification().getApiKey(), exchange .getExchangeSpecification().getSecretKey(), nonce); BitcoinToYouBaseTradeApiResult<BitcoinToYouBalance[]> accountInfo = bitcoinToYouAuthenticated.getBalance(exchange.getExchangeSpecification() .getApiKey(), nonce, signatureCreator, nonce); if (accountInfo.getSuccess() == 0) { throw new ExchangeException("Error getting account info: " + accountInfo.getError()); } return accountInfo; } }
public BitcoinToYouOrder[] placeBitcoinToYouLimitOrder(LimitOrder limitOrder) { Long nonce = exchange.getNonceFactory().createValue(); BitcoinToYouDigest signatureCreator = BitcoinToYouDigest.createInstance(exchange.getExchangeSpecification().getApiKey(), exchange .getExchangeSpecification().getSecretKey(), nonce); BitcoinToYouBaseTradeApiResult<BitcoinToYouOrder[]> userOrders = bitcoinToYouAuthenticated.createOrder(exchange.getExchangeSpecification() .getApiKey(), nonce, signatureCreator, nonce, limitOrder.getCurrencyPair().baseSymbol, limitOrder.getType() == Order.OrderType.BID ? "buy" : "sell", limitOrder.getTradableAmount(), limitOrder.getLimitPrice()); if (userOrders.getSuccess() == 0) { throw new ExchangeException("Error placing limit order: " + userOrders.getError()); } return userOrders.getTheReturn(); }