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

The following examples show how to use org.knowm.xchange.currency.Currency#equals() . 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: AlternateValueCalculator.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public float calculateValue(float baseAmount, Currency targetCurrency) throws ExchangeRateNotAvailableException {
    // convert the amount to btc first
    float btcAmount = calcBtcAmount(baseAmount);
    float targetValue;

    // if the target currency is btc we do nothing, otherwise we use the rate
    if (targetCurrency.equals(Currency.BTC)) {
        targetValue = btcAmount;
    } else {

        float fiatBtcPrice = exchangeRateProvider.getExchangeRate(new CurrencyPair(Currency.BTC, targetCurrency));
        targetValue = btcAmount * fiatBtcPrice;
    }

    return targetValue;
}
 
Example 2
Source File: AlternateValueCalculator.java    From android-wallet-app with GNU General Public License v3.0 6 votes vote down vote up
public float calculateValue(float baseAmount, Currency targetCurrency) throws ExchangeRateNotAvailableException {
    // convert the amount to btc first
    float btcAmount = calcBtcAmount(baseAmount);
    float targetValue;

    // if the target currency is btc we do nothing, otherwise we use the rate
    if (targetCurrency.equals(Currency.BTC)) {
        targetValue = btcAmount;
    } else {

        float fiatBtcPrice = exchangeRateProvider.getExchangeRate(new CurrencyPair(Currency.BTC, targetCurrency));
        targetValue = btcAmount * fiatBtcPrice;
    }

    return targetValue;
}
 
Example 3
Source File: AlternateValueUtils.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
private static String getSymbol(Currency currency) {
    if (currency.equals(Currency.BTC))
        return "Ƀ";
    else if (currency.equals(Currency.USD))
        return "$";
    else if (currency.equals(Currency.EUR))
        return "€";
    else if (currency.equals(Currency.CNY))
        return "¥";

    // should never happen:
    return "";
}
 
Example 4
Source File: AlternateValueUtils.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
private static String getSymbol(Currency currency) {
    if (currency.equals(Currency.BTC))
        return "Ƀ";
    else if (currency.equals(Currency.USD))
        return "$";
    else if (currency.equals(Currency.EUR))
        return "€";
    else if (currency.equals(Currency.CNY))
        return "¥";

    // should never happen:
    return "";
}