Return quotation between the base and another currency
335271
def rate(self, currency):
        """"""
        if not self._backend:
            raise ExchangeBackendNotInstalled()
        return self._backend.rate(currency)
410264
function getCurrencySettings(locale, localeData) {
  const currencyInfo = localeData.main(`numbers/currencies`);
  let currentCurrency = '';

  // find the currency currently used in this country
  const currencies =
    localeData.get(`supplemental/currencyData/region/${localeData.attributes.territory}`) ||
    localeData.get(`supplemental/currencyData/region/${localeData.attributes.language.toUpperCase()}`);

  if (currencies) {
    currencies.some(currency => {
      const keys = Object.keys(currency);
      return keys.some(key => {
        if (currency[key]._from && !currency[key]._to) {
          return currentCurrency = key;
        }
      });
    });

    if (!currentCurrency) {
      throw new Error(`Unable to find currency for locale "${locale}"`);
    }
  }

  let currencySettings = [undefined, undefined];

  if (currentCurrency) {
    currencySettings = [currencyInfo[currentCurrency].symbol, currencyInfo[currentCurrency].displayName];
  }

  return currencySettings;
}
245417
def ratechangebase(self, ratefactor, current_base, new_base):
        
        if self._multiplier is None:
            self.log(logging.WARNING, "CurrencyHandler: changing base ourselves")
            # Check the current base is 1
            if Decimal(1) != self.get_ratefactor(current_base, current_base):
                raise RuntimeError("CurrencyHandler: current baserate: %s not 1" % current_base)
            self._multiplier = Decimal(1) / self.get_ratefactor(current_base, new_base)
        return (ratefactor * self._multiplier).quantize(Decimal(".0001"))
963046
def get_currency(self):
        
        bika_setup = api.get_bika_setup()
        currency = bika_setup.getCurrency()
        currencies = locales.getLocale('en').numbers.currencies
        return currencies[currency]
513768
def convert(self, money, to_currency, date=None):
        
        if str(money.currency) == str(to_currency):
            return copy.copy(money)
        return Money(
            amount=money.amount
            * self.rate(money.currency, to_currency, date or datetime.date.today()),
            currency=to_currency,
        )
21813
private CurrencyData getCurrencyData(String code) {
    CurrencyData data = currencies.get(code);
    if (data == null) {
      data = new CurrencyData();
      data.setCode(code);
      currencies.put(code, data);
    }
    return data;
  }
731060
private Currency getCurrency(String currencyCode) {
        try {
            return Currency.getInstance(currencyCode);
        } catch (Exception e) {
            return null;
        }
    }
502115
def convert(amount, from_code, to_code, decimals=2, qs=None):
    """"""
    if from_code == to_code:
        return amount

    if qs is None:
        qs = get_active_currencies_qs()

    from_, to = qs.get(code=from_code), qs.get(code=to_code)

    amount = D(amount) * (to.factor / from_.factor)
    return price_rounding(amount, decimals=decimals)
30641
function generateBaseCurrencies(localeData, addDigits) {
  const currenciesData = localeData.main('numbers/currencies');
  const fractions = new cldrJs('en').get(`supplemental/currencyData/fractions`);
  const currencies = {};
  Object.keys(currenciesData).forEach(key => {
    let symbolsArray = [];
    const symbol = currenciesData[key].symbol;
    const symbolNarrow = currenciesData[key]['symbol-alt-narrow'];
    if (symbol && symbol !== key) {
      symbolsArray.push(symbol);
    }
    if (symbolNarrow && symbolNarrow !== symbol) {
      if (symbolsArray.length > 0) {
        symbolsArray.push(symbolNarrow);
      } else {
        symbolsArray = [undefined, symbolNarrow];
      }
    }
    if (addDigits && fractions[key] && fractions[key]['_digits']) {
      const digits = parseInt(fractions[key]['_digits'], 10);
      if (symbolsArray.length === 2) {
        symbolsArray.push(digits);
      } else if (symbolsArray.length === 1) {
        symbolsArray = [...symbolsArray, undefined, digits];
      } else {
        symbolsArray = [undefined, undefined, digits];
      }
    }
    if (symbolsArray.length > 0) {
      currencies[key] = symbolsArray;
    }
  });
  return currencies;
}
1091927
def get_exchange_rate(base, target, *args, **kwargs):
    
    return Cryptonator().get_exchange_rate(base, target, *args, **kwargs)
1147419
def assert_currency! arg
      defines?(arg) ? (country_map[arg] || arg) : raise(Exchange::NoCurrencyError.new("#{arg} is not a currency nor a country code matchable to a currency"))
    end
459092
def quote(self, s):
        """"""

        if six.PY2:
            from pipes import quote
        else:
            from shlex import quote

        return quote(s)
26387
def convert_money(self, money: Money, to: str, reverse: bool=False) -> Money:
        """"""
        converted = self.convert(money.amount, money.currency, to, reverse)
        return Money(converted, to)
1006579
function get(currency, callback) {
  if(['BTC', 'USD', 'AUD', 'NZD', 'CAD', 'EUR', 'GBP', 'SGD', 'HKD', 'CHF', 'JPY'].indexOf(currency) === -1) {
    throw new Error('specified currency is not supported');
  }

  if(!util.isFunction(callback)) {
    throw new Error('callback must be a function');
  }

  var resource = this.coinjar.personal.api_endpoint +
    '/v1/fair_rate/' +
    currency +
    '.json';

  request.get(resource)
    .auth(this.coinjar.personal.auth_token)
    .end(function (response) {
      if(isResponseError(response, callback)) { return; }
      return callback(null, response.body);
    });
}
928506
def validate_currency(*currencies):
	
	validated_currency = []
	if not currencies:
		raise CurrencyException('My function need something to run, duh')
	for currency in currencies:
		currency = currency.upper()
		if not isinstance(currency, str):
			raise TypeError('Currency code should be a string: ' + repr(currency))
		if currency not in _currencies:
			raise CurrencyException('Currency code not found: ' + repr(currency))
		validated_currency.append(currency)
	return validated_currency[0] if len(validated_currency) == 1 else validated_currency
1196128
def load_currency(self, mnemonic: str):
        
        # , base_currency: str <= ignored for now.
        if self.rate and self.rate.currency == mnemonic:
            # Already loaded.
            return

        app = PriceDbApplication()
        # TODO use the base_currency parameter for the query #33
        symbol = SecuritySymbol("CURRENCY", mnemonic)
        self.rate = app.get_latest_price(symbol)
        if not self.rate:
            raise ValueError(f"No rate found for {mnemonic}!")
1196406
private String getCurrencyFormat(CurrencySymbolPosition position)
   {
      String result;

      switch (position)
      {
         case AFTER:
         {
            result = "1.1#";
            break;
         }

         case AFTER_WITH_SPACE:
         {
            result = "1.1 #";
            break;
         }

         case BEFORE_WITH_SPACE:
         {
            result = "# 1.1";
            break;
         }

         default:
         case BEFORE:
         {
            result = "#1.1";
            break;
         }
      }

      return result;
   }