Create the currency dictionary
13694
def make_ccys(db):
    '''
    
    '''
    dfr = 4
    dollar = r'\u0024'
    peso = r'\u20b1'
    kr = r'kr'
    insert = db.insert

    # G10 & SCANDI
    insert('EUR', '978', 'EU', 1,
           'Euro', dfr, 'EU', '30/360', 'ACT/360',
           future='FE', symbol=r'\u20ac', html='&#x20ac;')
    insert('GBP', '826', 'BP', 2,
           'British Pound', dfr, 'GB', 'ACT/365', 'ACT/365',
           symbol=r'\u00a3', html='&#xa3;')
    insert('AUD', '036', 'AD', 3,
           'Australian Dollar', dfr, 'AU', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('NZD', '554', 'ND', 4,
           'New-Zealand Dollar', dfr, 'NZ', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('USD', '840', 'UD', 5,
           'US Dollar', 0, 'US', '30/360', 'ACT/360',
           future='ED', symbol=dollar, html='&#x24;')
    insert('CAD', '124', 'CD', 6,
           'Canadian Dollar', dfr, 'CA', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('CHF', '756', 'SF', 7,
           'Swiss Franc', dfr, 'CH', '30/360', 'ACT/360',
           symbol=r'Fr', html='&#x20a3;')
    insert('NOK', '578', 'NK', 8,
           'Norwegian Krona', dfr, 'NO', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('SEK', '752', 'SK', 9,
           'Swedish Krona', dfr, 'SE', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('DKK', '208', 'DK', 10,
           'Danish Krona', dfr, 'DK', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('JPY', '392', 'JY', 10000,
           'Japanese Yen', 2,  'JP', 'ACT/365', 'ACT/360',
           symbol=r'\u00a5', html='&#xa5;')

    # ASIA
    insert('CNY', '156', 'CY', 680,
           'Chinese Renminbi', dfr, 'CN', 'ACT/365', 'ACT/365',
           symbol=r'\u00a5', html='&#xa5;')
    insert('KRW', '410', 'KW', 110000,
           'South Korean won', 2, 'KR', 'ACT/365', 'ACT/365',
           symbol=r'\u20a9', html='&#x20a9;')
    insert('SGD', '702', 'SD', 15,
           'Singapore Dollar', dfr, 'SG', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('IDR', '360', 'IH', 970000,
           'Indonesian Rupiah', 0, 'ID', 'ACT/360', 'ACT/360',
           symbol=r'Rp', html='Rp')
    insert('THB', '764', 'TB', 3300,
           'Thai Baht', 2, 'TH', 'ACT/365', 'ACT/365',
           symbol=r'\u0e3f', html='&#xe3f;')
    insert('TWD', '901', 'TD', 18,
           'Taiwan Dollar', dfr, 'TW', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('HKD', '344', 'HD', 19,
           'Hong Kong Dollar', dfr, 'HK', 'ACT/365', 'ACT/365',
           symbol=r'\u5713', html='HK&#x24;')
    insert('PHP', '608', 'PP', 4770,
           'Philippines Peso', dfr, 'PH', 'ACT/360', 'ACT/360',
           symbol=peso, html='&#x20b1;')
    insert('INR', '356', 'IR', 4500,
           'Indian Rupee', dfr, 'IN', 'ACT/365', 'ACT/365',
           symbol=r'\u20a8', html='&#x20a8;')
    insert('MYR', '458', 'MR', 345,
           'Malaysian Ringgit', dfr, 'MY', 'ACT/365', 'ACT/365')
    insert('VND', '704', 'VD', 1700000,
           'Vietnamese Dong', 0,  'VN', 'ACT/365', 'ACT/365',
           symbol=r'\u20ab', html='&#x20ab;')

    # LATIN AMERICA
    insert('BRL', '986', 'BC', 200,
           'Brazilian Real', dfr, 'BR', 'BUS/252', 'BUS/252',
           symbol=r'R$')
    insert('PEN', '604', 'PS', 220,
           'Peruvian New Sol', dfr, 'PE', 'ACT/360', 'ACT/360',
           symbol=r'S/.')
    insert('ARS', '032', 'AP', 301,
           'Argentine Peso', dfr, 'AR', '30/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('MXN', '484', 'MP', 1330,
           'Mexican Peso', dfr, 'MX', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('CLP', '152', 'CH', 54500,
           'Chilean Peso', 2,  'CL', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('COP', '170', 'CL', 190000,
           'Colombian Peso', 2,  'CO', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('JMD', '388', 'JD', 410,
           'Jamaican Dollar', dfr, 'JM', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('TTD', '780', 'TT', 410,
           'Trinidad and Tobago Dollar', dfr, 'TT', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('BMD', '060', 'BD', 410,
           'Bermudian Dollar', dfr, 'BM',
           symbol=dollar, html='&#x24;')

    # EASTERN EUROPE
    insert('CZK', '203', 'CK', 28,
           'Czech Koruna', dfr, 'CZ', 'ACT/360', 'ACT/360',
           symbol=r'\u004b\u010d')
    insert('PLN', '985', 'PZ', 29,
           'Polish Zloty', dfr, 'PL', 'ACT/ACT', 'ACT/365',
           symbol=r'\u0050\u0142')
    insert('TRY', '949', 'TY', 30,
           'Turkish Lira', dfr, 'TR', 'ACT/360', 'ACT/360',
           symbol=r'\u0054\u004c')
    insert('HUF', '348', 'HF', 32,
           'Hungarian Forint', dfr, 'HU', 'ACT/365', 'ACT/360',
           symbol=r'Ft', html='Ft')
    insert('RON', '946', 'RN', 34,
           'Romanian Leu', dfr, 'RO', 'ACT/360', 'ACT/360')
    insert('RUB', '643', 'RR', 36,
           'Russian Ruble', dfr, 'RU', 'ACT/ACT', 'ACT/ACT',
           symbol=r'\u0440\u0443\u0431')
    # TODO: Check towletters code and position
    insert('HRK', '191', 'HK', 410,
           'Croatian kuna', dfr, 'HR',
           symbol=r'kn')
    # TODO: Check towletters code and position
    insert('KZT', '398', 'KT', 410,
           'Tenge',  dfr, 'KZ',
           symbol=r'\u20b8', html='&#x20b8;')
    # TODO: Check towletters code and position
    insert('BGN', '975', 'BN', 410,
           'Bulgarian Lev', dfr, 'BG',
           symbol=r'\u043b\u0432.', html='&#1083;&#1074;')

    # MIDDLE EAST & AFRICA
    insert('ILS', '376', 'IS', 410,
           'Israeli Shekel', dfr, 'IL', 'ACT/365', 'ACT/365',
           symbol=r'\u20aa', html='&#x20aa;')
    # TODO: Check towletters code and position
    insert('AED', '784', 'AE', 410,
           'United Arab Emirates Dirham', dfr, 'AE')
    # TODO: Check towletters code and position
    insert('QAR', '634', 'QA', 410,
           'Qatari Riyal', dfr, 'QA',
           symbol=r'\ufdfc', html='&#xfdfc;')
    # TODO: Check towletters code and position
    insert('SAR', '682', 'SR', 410,
           'Saudi Riyal', dfr, 'SA',
           symbol=r'\ufdfc', html='&#xfdfc;')
    insert('EGP', '818', 'EP', 550,
           'Egyptian Pound', dfr, 'EG',
           symbol=r'\u00a3', html='&#xa3;')
    insert('ZAR', '710', 'SA', 750,
           'South African Rand', dfr, 'ZA', 'ACT/365', 'ACT/365',
           symbol=r'R', html='R')

    # BITCOIN
    insert('XBT', '000', 'BT', -1,
           'Bitcoin', 8, 'WW',
           symbol=r'\u0e3f', html='&#xe3f;')
1227322
def currency(s=''):
    ''
    if isinstance(s, str):
        s = ''.join(ch for ch in s if ch in floatchars)
    return float(s) if s else TypedWrapper(float, None)
379834
public function formatCurrency()
    {
        $currencies = json_decode(file_get_contents(__DIR__.'/../Currencies.json'));
        $currency = $this->currency;

        return $currencies->$currency;
    }
1071287
def _fx_mapping(raw_rates):
    '''  '''
    return {pair[0].lower(): {
        'timeStamp': pair[1],
        'bid': float(pair[2] + pair[3]),
        'ask': float(pair[4] + pair[5]),
        'high': float(pair[6]),
        'low': float(pair[7])
    } for pair in map(lambda x: x.split(','), raw_rates)}
490093
def to_dict(self):
        

        return {
            "total": self.total,
            "subtotal": self.subtotal,
            "items": self.items,
            "extra_amount": self.extra_amount
        }
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)
129392
private void writeCurrency()
   {
      ProjectProperties props = m_projectFile.getProjectProperties();
      CurrencyType currency = m_factory.createCurrencyType();
      m_apibo.getCurrency().add(currency);

      String positiveSymbol = getCurrencyFormat(props.getSymbolPosition());
      String negativeSymbol = "(" + positiveSymbol + ")";

      currency.setDecimalPlaces(props.getCurrencyDigits());
      currency.setDecimalSymbol(getSymbolName(props.getDecimalSeparator()));
      currency.setDigitGroupingSymbol(getSymbolName(props.getThousandsSeparator()));
      currency.setExchangeRate(Double.valueOf(1.0));
      currency.setId("CUR");
      currency.setName("Default Currency");
      currency.setNegativeSymbol(negativeSymbol);
      currency.setObjectId(DEFAULT_CURRENCY_ID);
      currency.setPositiveSymbol(positiveSymbol);
      currency.setSymbol(props.getCurrencySymbol());
   }
364257
def set_currency(self, currency_id):
        
        try:
            self.currency = currency_codes[currency_id]
            self.IsoMessage.FieldData(49, self.currency)
            self.rebuild()
        except KeyError:
            self.currency = None
895681
def convert(from_currency, to_currency, from_currency_price=1):
	
	get_cache()
	from_currency, to_currency = validate_currency(from_currency, to_currency)
	update_cache(from_currency, to_currency)
	return ccache[from_currency][to_currency]['value'] * from_currency_price
654548
def set_money_currency(self, money_currency):
        
        if money_currency not in self.money_formats:
            raise CurrencyDoesNotExist

        self.money_currency = money_currency
1359555
def install_money_setter attribute, options={}
      define_method :"#{attribute}_with_exchange_typecasting=" do |data|
        att      = send(attribute)
        currency = evaluate_money_option(options[:currency])
        
        attribute_setter = :"#{attribute}_without_exchange_typecasting="
        
        send(attribute_setter, if !data.respond_to?(:currency)
          data
        elsif currency == data.currency
          data.value
        elsif currency != data.currency
          data.to(currency).value
        end)
      end
      exchange_typecasting_alias_method_chain attribute, '='
    end
387923
def create(**kwargs):
        
        secType = kwargs.get('secType', '')
        cls = {
            '': Contract,
            'STK': Stock,
            'OPT': Option,
            'FUT': Future,
            'CONTFUT': ContFuture,
            'CASH': Forex,
            'IND': Index,
            'CFD': CFD,
            'BOND': Bond,
            'CMDTY': Commodity,
            'FOP': FuturesOption,
            'FUND': MutualFund,
            'WAR': Warrant,
            'IOPT': Warrant,
            'BAG': Bag,
            'NEWS': Contract
        }.get(secType, Contract)
        if cls is not Contract:
            kwargs.pop('secType', '')
        return cls(**kwargs)
189036
function currencies() {
    global $db;
    $this->currencies = array();
    $currencies_query = "select code, title, symbol_left, symbol_right, decimal_point,
                                  thousands_point, decimal_places, value
                          from " . TABLE_CURRENCIES;

    $currencies = $db->Execute($currencies_query);

    while (!$currencies->EOF) {
      $this->currencies[$currencies->fields['code']] = array('title' => $currencies->fields['title'],
      'symbol_left' => $currencies->fields['symbol_left'],
      'symbol_right' => $currencies->fields['symbol_right'],
      'decimal_point' => $currencies->fields['decimal_point'],
      'thousands_point' => $currencies->fields['thousands_point'],
      'decimal_places' => $currencies->fields['decimal_places'],
      'value' => $currencies->fields['value']);

      $currencies->MoveNext();
    }
  }
1235344
def name(currency, *, plural=False):
	
	currency = validate_currency(currency)
	if plural:
		return _currencies[currency]['name_plural']
	return _currencies[currency]['name']
376538
public static function currencyList()
    {
        $path = dirname(realpath(__FILE__)).DIRECTORY_SEPARATOR.'data/currency.json';
        $currency = self::readJson($path, true);

        $listCurrency = [];

        foreach ($currency['Names'] as $code => $value) {
            $listCurrency[$code] = $value[1];
        }

        return $listCurrency;
    }
972425
private void quickSetup() {
        initialiseDatabase();
        Common.getInstance().initializeCurrency();
        Currency currency = Common.getInstance().getCurrencyManager().addCurrency(getMainConfig().getString("System.QuickSetup.Currency.Name"), getMainConfig().getString("System.QuickSetup.Currency.NamePlural"), getMainConfig().getString("System.QuickSetup.Currency.Minor"), getMainConfig().getString("System.QuickSetup.Currency.MinorPlural"), getMainConfig().getString("System.QuickSetup.Currency.Sign"), true);
        Common.getInstance().getCurrencyManager().setDefault(currency);
        Common.getInstance().getCurrencyManager().setDefaultBankCurrency(currency);
        getStorageHandler().getStorageEngine().setConfigEntry("longmode", DisplayFormat.valueOf(getMainConfig().getString("System.QuickSetup.DisplayMode").toUpperCase()).toString());
        getStorageHandler().getStorageEngine().setConfigEntry("holdings", getMainConfig().getString("System.QuickSetup.StartBalance"));
        getStorageHandler().getStorageEngine().setConfigEntry("bankprice", getMainConfig().getString("System.QuickSetup.PriceBank"));
        initializeCurrency();
        loadDefaultSettings();
        Common.getInstance().startUp();
        Common.getInstance().getMainConfig().setValue("System.Setup", false);
        commandManager.setCurrentLevel(1);
        sendConsoleMessage(Level.INFO, "Quick-Config done!");
    }
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}!")