@Override public boolean cancelOrder(String orderId) throws IOException { throw new ExchangeException( "You need to provide the currency pair, the order id and the order type to cancel an order."); }
private static void generic(Exchange exchange) throws IOException { TradeService tradeService = exchange.getTradeService(); try { DSXTradeHistoryParams params = new DSXTradeHistoryParams(); params.setCurrencyPair(CurrencyPair.BTC_USD); UserTrades trades = tradeService.getTradeHistory(params); System.out.println(trades.toString()); } catch (ExchangeException e) { System.out.println(e.getMessage()); } }
private org.knowm.xchange.luno.dto.trade.OrderType convertForLimit(OrderType type) { switch (type) { case ASK: return org.knowm.xchange.luno.dto.trade.OrderType.ASK; case BID: return org.knowm.xchange.luno.dto.trade.OrderType.BID; default: throw new ExchangeException("Not supported order type: " + type); } }
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 long symbolId(CurrencyPair pair) { Long symbolId = pairs.get(pair); if (symbolId == null) { throw new ExchangeException("Not supported pair " + pair + " by Dragonex."); } return symbolId; }
public static String translateBitmexContract(BitmexContract contractIn) { String contractOut = bitmexContracts.inverse().get(contractIn); if (contractOut == null) { throw new ExchangeException("Bitmex does not support the contact " + contractIn); } return contractOut; }
public static Currency translateBitmexCurrency(String currencyIn) { Currency currencyOut = bitmexCurrencies.inverse().get(currencyIn); if (currencyOut == null) { throw new ExchangeException("Bitmex does not support the currency code " + currencyIn); } return currencyOut; }
private static Date adaptDate(String date) { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date result; try { result = format.parse(date); } catch (ParseException e) { throw new ExchangeException("Date/time parse error: " + e.getMessage()); } return result; }
public static Date nanos2Date(String nanos) { // timestamp is provided in nano seconds! try { long millis = Long.valueOf(nanos.substring(0, nanos.length() - 6)); return new Date(millis); } catch (Throwable e) { throw new ExchangeException("Invalid timestamp provided by dragonex: " + nanos); } } }
public String transferToTrading(Currency currency, BigDecimal amount) throws IOException { HitbtcInternalTransferResponse response = transferFunds(currency, amount, HitbtcTransferType.BANK_TO_EXCHANGE); if (response.id == null) { throw new ExchangeException("transfer failed: " + response); } return response.id; }
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 static ExchangeException adapt(LivecoinException e) { String message = e.getErrorMessage(); if (StringUtils.isEmpty(message)) { return new ExchangeException("Operation failed without any error message"); } if (message.startsWith(UNKNOWN_CURRENCY_MESSAGE_START)) { return new CurrencyPairNotValidException(message); } return new ExchangeException(message); } }
public static <T extends LakeBTCResponse> T checkResult(T returnObject) { if (returnObject.getResult() == null) { throw new ExchangeException("Null data returned"); } return returnObject; } }
public static ExchangeException adapt(CryptopiaException e) { String message = e.getError(); if (StringUtils.isEmpty(message)) { return new ExchangeException("Operation failed without any error message"); } if (MARKET_NOT_FOUND_PATTERN.matcher(message).matches()) { return new CurrencyPairNotValidException(message); } return new ExchangeException(message); } }
public <R> R checkResult(BxResult<R> bxResult) { if (!bxResult.isSuccess()) { String bxError = bxResult.getError(); if (bxError.isEmpty()) { throw new ExchangeException("Missing error message"); } else { throw new ExchangeException(bxError); } } return bxResult.getResult(); } }
protected <R> R checkResult(HuobiResult<R> huobiResult) { if (!huobiResult.isSuccess()) { String huobiError = huobiResult.getError(); if (huobiError.length() == 0) { throw new ExchangeException("Missing error message"); } else { throw new ExchangeException(huobiError); } } return huobiResult.getResult(); }
public static String getKrakenCurrencyCode(Currency currency) { if (currency.getIso4217Currency() != null) { currency = currency.getIso4217Currency(); } String krakenCode = assetsMapReverse.get(currency); if (krakenCode == null) { throw new ExchangeException("Kraken does not support the currency code " + currency); } return krakenCode; }
public QuoineProduct getQuoineProduct(String currencyPair) throws IOException { try { return quoine.getQuoineProduct(currencyPair); } catch (HttpStatusIOException e) { throw new ExchangeException(e.getHttpBody(), e); } }
public List<ZaifMarket> getAllMarkets() { try { return this.zaif.getCurrencyPairs(); } catch (ZaifException e) { throw new ExchangeException(e.getMessage()); } }
public VaultoroCancelOrderResponse cancelVaultoroOrder(String orderId) throws IOException { try { VaultoroCancelOrderResponse response = vaultoro.cancel(orderId, exchange.getNonceFactory(), apiKey, signatureCreator); return response; } catch (VaultoroException e) { throw new ExchangeException(e); } }