Normalise this balance into a single currency

        Args:
            to_currency (str): Destination currency

        Returns:
            (Balance): A new balance object containing a single Money value in the specified currency
169118
def normalise(self, to_currency):
        
        out = Money(currency=to_currency)
        for money in self._money_obs:
            out += converter.convert(money, to_currency)
        return Balance([out])
104816
def __store_cash_balances_per_currency(self, cash_balances):
        
        cash = self.model.get_cash_asset_class()

        for cur_symbol in cash_balances:
            item = CashBalance(cur_symbol)
            item.parent = cash
            
            quantity = cash_balances[cur_symbol]["total"]
            item.value = Decimal(quantity)
            item.currency = cur_symbol

            # self.logger.debug(f"adding {item}")
            cash.stocks.append(item)
            self.model.stocks.append(item)
781262
def formatCurrency( value, options = nil )
      value ||= "0.00"
      if !value.include?( '.' )
         value << ".00"
      end
      
      currencySymbol = currencyFormat = nil
      if options
         currencySymbol = options["currencySymbol"]
         currencyFormat = options["currencyFormat"]
      end
      
      if currencySymbol
         if currencyFormat
            if currencyFormat == "0"
               value = "#{currencySymbol}#{value}"
            elsif currencyFormat == "1"
               if value.include?("-")
                  value.gsub!("-","-#{currencySymbol}")
               elsif value.include?("+")
                  value.gsub!("+","+#{currencySymbol}")
               else   
                  value = "#{currencySymbol}#{value}"
               end
            elsif currencyFormat == "2"
               value = "#{value}#{currencySymbol}"
            end
         else
            value = "#{currencySymbol}#{value}"
         end
      end
      
      value
   end
395572
def currency
      # Mixing currency not allowed; this
      # library can't convert between
      # currencies.
      currencies = @contents.map { |item| item[:currency] }.uniq || "USD"

      case currencies.count
        when 0
          "USD"
        when 1
          currencies.first
        else
          raise RuntimeError.new("Mixing currency not allowed")
      end

    end
617676
def loads(cls, s: str) -> 'Money':
        """"""
        try:
            currency, amount = s.strip().split()
            return cls(amount, currency)
        except ValueError as err:
            raise ValueError("failed to parse string "
                             " '{}': {}".format(s, err))
939759
function convertFromLocaleCurrency( $toCurrency, $value, $applyRounding = true )
    {
        $locale = eZLocale::instance();
        $fromCurrency = $locale->currencyShortName();
        $retValue = $this->convert( $fromCurrency, $toCurrency, $value, $applyRounding );
        return $retValue;
    }
578330
def list_currency_rates(self, from_currency=None):
        
        return self.make_api_request(
            'Account',
            'listCurrencyRates',
            utils.get_kwargs(locals()),
            model=models.CurrencyRate,
        )
844715
def price(self, minimum: float = 10.00,
              maximum: float = 1000.00) -> str:
        
        price = self.random.uniform(minimum, maximum, precision=2)
        return '{0} {1}'.format(price, self.currency_symbol())
1181104
def __get_default_currency(self):
        """"""
        # If we are on Windows, read from registry.
        if sys.platform == "win32":
            # read from registry
            def_curr = self.book["default-currency"] = self.__get_default_currency_windows()
        else:
            # return the currency from locale.
            # todo: Read the preferences on other operating systems.
            def_curr = self.book["default-currency"] = self.__get_locale_currency()

        return def_curr
1373450
public BigMoney toBigMoney() {
        if (currency == null) {
            throw new MoneyFormatException("Cannot convert to BigMoney as no currency found");
        }
        if (amount == null) {
            throw new MoneyFormatException("Cannot convert to BigMoney as no amount found");
        }
        return BigMoney.of(currency, amount);
    }
1071236
public function convert($amount, $from_currency, $to_currency)
    {
        if ($from_currency === $to_currency) {
            return $amount; // Nothing to convert
        }

        $currency = $this->get($from_currency);
        $target_currency = $this->get($to_currency);

        $exponent = $target_currency['decimals'] - $currency['decimals'];
        $amount *= pow(10, $exponent);

        return $amount * ($currency['conversion_rate'] / $target_currency['conversion_rate']);
    }
45224
def loads(cls, s):
        """"""
        try:
            currency, amount = s.strip().split(' ')
            return cls(amount, currency)
        except ValueError as err:
            # RADAR: Python2
            money.six.raise_from(ValueError("failed to parse string "
                " '{}': {}".format(s, err)), None)
799498
def check_update(from_currency, to_currency):
	
	if from_currency not in ccache: # if currency never get converted before
		ccache[from_currency] = {}
	if ccache[from_currency].get(to_currency) is None:
		ccache[from_currency][to_currency] = {'last_update': 0}
	last_update = float(ccache[from_currency][to_currency]['last_update'])
	if time.time() - last_update >= 30 * 60: # if last update is more than 30 min ago
		return True
	return False
984506
def create_from_label_monetary_account(cls, label_monetary_account):
        

        instance = cls.__new__(cls)
        instance.label_monetary_account = label_monetary_account
        instance.pointer = Pointer()
        instance.pointer._name = label_monetary_account.display_name
        instance.pointer._type_ = cls._POINTER_TYPE_IBAN
        instance.pointer._value = label_monetary_account.iban

        return instance
1271608
def valueFromText( self, text ):
        
        value, currency = projex.money.fromString(text)
        
        return value
731060
private Currency getCurrency(String currencyCode) {
        try {
            return Currency.getInstance(currencyCode);
        } catch (Exception e) {
            return null;
        }
    }
854920
def convert_btc_to_cur(self, coins, currency):
        
        if isinstance(coins, Decimal):
            use_decimal = True
        else:
            use_decimal = self._force_decimal

        url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(currency)
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            price = data.get('bpi').get(currency, {}).get('rate_float', None)
            if price:
                if use_decimal:
                    price = Decimal(price)
                try:
                    converted_amount = coins * price
                    return converted_amount
                except TypeError:
                    raise DecimalFloatMismatchError("convert_btc_to_cur requires coins parameter is of type Decimal when force_decimal=True")
        raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given date")