Java Code Examples for org.knowm.xchange.currency.Currency#getCurrencyCode()

The following examples show how to use org.knowm.xchange.currency.Currency#getCurrencyCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoinbaseTradeServiceRaw.java    From zheshiyigeniubidexiangmu with MIT License 6 votes vote down vote up
/**
 * Authenticated resource that lets you purchase Bitcoin using the primary bank account that is
 * linked to your account. (You must link and verify your bank account through the website before
 * this API call will work). The underlying optional parameter agree_btc_amount_varies is set to
 * false.
 *
 * @see <a
 *     href="https://developers.coinbase.com/api/v2#place-buy-order">developers.coinbase.com/api/v2#place-buy-order</a>
 */
public CoinbaseBuy buy(String accountId, BigDecimal total, Currency currency, boolean commit)
    throws IOException {

  String path = "/v2/accounts/" + accountId + "/buys";
  String apiKey = exchange.getExchangeSpecification().getApiKey();
  BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
  BuyPayload payload = new BuyPayload(total, currency.getCurrencyCode(), commit, false);
  String body = new ObjectMapper().writeValueAsString(payload);
  String signature = getSignature(timestamp, HttpMethod.POST, path, body);

  showCurl(HttpMethod.POST, apiKey, timestamp, signature, path, body);

  return coinbase
      .buy(
          MediaType.APPLICATION_JSON,
          Coinbase.CB_VERSION_VALUE,
          apiKey,
          signature,
          timestamp,
          accountId,
          payload)
      .getData();
}
 
Example 2
Source File: BitmexAccountService.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {
  String currencyCode = currency.getCurrencyCode();

  // bitmex seems to use a lowercase 't' in XBT
  // can test this here - https://testnet.bitmex.com/api/explorer/#!/User/User_getDepositAddress
  // uppercase 'T' will return 'Unknown currency code'
  if (currencyCode.equals("XBT")) {
    currencyCode = "XBt";
  }
  return requestDepositAddress(currencyCode);
}
 
Example 3
Source File: BiboxAccountService.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) {

  if (!(params instanceof TradeHistoryParamCurrency)) {
    throw new RuntimeException("You must provide the currency for funding history @ Bibox.");
  }
  Currency c = ((TradeHistoryParamCurrency) params).getCurrency();
  if (c == null) {
    throw new RuntimeException("You must provide the currency for funding history @ Bibox.");
  }

  boolean deposits = false;
  boolean withdrawals = false;
  if (params instanceof HistoryParamsFundingType) {
    HistoryParamsFundingType typeParams = (HistoryParamsFundingType) params;
    Type type = typeParams.getType();
    deposits = type == null || type == Type.DEPOSIT;
    withdrawals = type == null || type == Type.WITHDRAWAL;
  }
  BiboxFundsCommandBody body = new BiboxFundsCommandBody(c.getCurrencyCode());
  ArrayList<FundingRecord> result = new ArrayList<>();
  if (deposits) {
    requestBiboxDeposits(body).getItems().forEach(d -> result.add(BiboxAdapters.adaptDeposit(d)));
  }
  if (withdrawals) {
    requestBiboxWithdrawals(body)
        .getItems()
        .forEach(d -> result.add(BiboxAdapters.adaptDeposit(d)));
  }
  return result;
}
 
Example 4
Source File: BinanceAccountService.java    From zheshiyigeniubidexiangmu with MIT License 4 votes vote down vote up
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
    throws ExchangeException, NotAvailableFromExchangeException,
        NotYetImplementedForExchangeException, IOException {
  return super.withdraw(currency.getCurrencyCode(), address, amount);
}
 
Example 5
Source File: BitfinexAccountService.java    From zheshiyigeniubidexiangmu with MIT License 4 votes vote down vote up
@Override
public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
  final BitfinexDepositAddressResponse response =
      super.requestDepositAddressRaw(currency.getCurrencyCode());
  return response.getAddress();
}
 
Example 6
Source File: OkCoinAccountService.java    From zheshiyigeniubidexiangmu with MIT License 4 votes vote down vote up
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
    throws IOException {
  boolean useIntl =
      this.exchange
          .getExchangeSpecification()
          .getExchangeSpecificParametersItem("Use_Intl")
          .equals(true);
  String currencySymbol =
      OkCoinAdapters.adaptSymbol(
          new CurrencyPair(currency, useIntl ? Currency.USD : Currency.CNY));

  String fee;
  switch (currency.getCurrencyCode()) {
    case "BTC":
      fee = "0.0015";
      break;
    case "LTC":
    case "ETC":
    case "BTG":
    case "ZEC":
      fee = "0.001";
      break;
    case "ETH":
    case "XLM":
    case "QTUM":
      fee = "0.01";
      break;
    case "OMG":
      fee = "0.1";
      break;
    case "BCH":
      fee = "0.0001";
      break;
    case "XRP":
      fee = "0.15";
      break;
    case "DASH":
      fee = "0.002";
      break;
    case "NEO":
      fee = "0";
      break;
    case "AVT":
      fee = "1";
      break;
    case "EOS":
      fee = "1.5";
      break;
    case "ELF":
      fee = "3";
      break;
    case "XEM":
      fee = "4";
      break;
    case "FUN":
      fee = "40";
      break;
    case "MANA":
    case "USDT":
    case "RCN":
      fee = "20";
      break;
    case "SNT":
      fee = "50";
      break;
    default:
      throw new IllegalArgumentException("Unsupported withdraw currency " + currency);
  }

  // Defualt withdraw target is external address. Use withdraw function in OkCoinAccountServiceRaw
  // for internal withdraw
  OKCoinWithdraw result = withdraw(currencySymbol, address, amount, "address", fee);

  if (result != null) return result.getWithdrawId();

  return "";
}