Return a dict of information about the currency
497779
def get_info(self, code):
        """"""
        currency = self.get_currency(code)
        info = {}

        users = list(filter(None, currency['users'].split(',')))
        if users:
            info['Users'] = users

        alt = list(filter(None, currency['alternatives'].split(',')))
        if alt:
            info['Alternatives'] = alt

        if self.modified:
            info['YFUpdate'] = self.modified.isoformat()

        return info
390224
def get_rate(self, currency, date):
        
        if str(currency) == defaults.INTERNAL_CURRENCY:
            return Decimal(1)

        cached = cache.get(_cache_key(currency, date))
        if cached:
            return Decimal(cached)
        else:
            # Expect self._get_rate() to implement caching
            return Decimal(self._get_rate(currency, date))
74470
def values(self) -> typing.Dict[str, str]:
        """"""
        return {k: v for k, v in self._items if v is not None}
74302
def _format_dict(self, info_dict):
        """"""
        for key, value in info_dict.items():
            if not value:
                info_dict[key] = "NA"
        return info_dict
896516
def info(self):
        
        url = "{}/v7/finance/quote?symbols={}".format(
            self._base_url, self.ticker)
        r = _requests.get(url=url).json()["quoteResponse"]["result"]
        if len(r) > 0:
            return r[0]
        return {}
1367875
def get_currencysymbol(self, code):
        """"""
        if not self._symbols:
            symbolpath = os.path.join(self._dir, 'currencies.json')
            with open(symbolpath, encoding='utf8') as df:
                self._symbols = json.load(df)
        return self._symbols.get(code)
974247
def info(self):
        """"""
        itext = self.class_info
        if self.key_prop.info and self.value_prop.info:
            itext += ' (keys: {}; values: {})'.format(
                self.key_prop.info, self.value_prop.info
            )
        elif self.key_prop.info:
            itext += ' (keys: {})'.format(self.key_prop.info)
        elif self.value_prop.info:
            itext += ' (values: {})'.format(self.value_prop.info)
        return itext
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();
    }
  }
542039
def raw(self) -> str:
        
        doc = """Version: {0}
Type: Transaction
Currency: {1}
""".format(self.version,
           self.currency)

        if self.version >= 3:
            doc += "Blockstamp: {0}\n".format(self.blockstamp)

        doc += "Locktime: {0}\n".format(self.locktime)

        doc += "Issuers:\n"
        for p in self.issuers:
            doc += "{0}\n".format(p)

        doc += "Inputs:\n"
        for i in self.inputs:
            doc += "{0}\n".format(i.inline(self.version))

        doc += "Unlocks:\n"
        for u in self.unlocks:
            doc += "{0}\n".format(u.inline())

        doc += "Outputs:\n"
        for o in self.outputs:
            doc += "{0}\n".format(o.inline())

        doc += "Comment: "
        doc += "{0}\n".format(self.comment)

        return doc
34462
def get_exchange_rate(self, base, target, raise_errors=True):
        """"""
        assert base and target

        base, target = base.lower(), target.lower()

        r = self.session.get(API_SIMPLE_TICKER.format(base, target))
        if r.status_code != requests.codes.ok:
            if not raise_errors:
                return None
            raise CryptonatorException(
                ("An error occurred while getting requested exchange rate "
                 "({} from Cryptonator).").format(r.status_code)
            )

        j = r.json()
        if not j['success'] or j['error']:
            if not raise_errors:
                return None
            raise CryptonatorException(
                ("An error occurred while getting requested exchange rate ({}, {})"
                 "('{}').").format(base, target, j['error'])
            )

        return float(j['ticker']['price'])
413945
def update(self):
        
        currencies = self.get_currencies()
        currency_objects = {}
        for code, name in currencies:
            currency_objects[code], created = Currency.objects.get_or_create(
                code=code, defaults={'name': name})
            if created:
                logger.info('currency: %s created', code)
        existing = ExchangeRate.objects.values('source__code',
                                               'target__code',
                                               'id')
        existing = {(d['source__code'], d['target__code']): d['id']
                    for d in existing}
        usd_exchange_rates = dict(self.get_exchangerates('USD'))
        updates = []
        inserts = []
        for source in currencies:
            for target in currencies:
                rate = self._get_rate_through_usd(source.code,
                                                  target.code,
                                                  usd_exchange_rates)

                exchange_rate = ExchangeRate(source=currency_objects[source.code],
                                             target=currency_objects[target.code],
                                             rate=rate)

                if (source.code, target.code) in existing:
                    exchange_rate.id = existing[(source.code, target.code)]
                    updates.append(exchange_rate)
                    logger.debug('exchange rate updated %s/%s=%s'
                                 % (source, target, rate))
                else:
                    inserts.append(exchange_rate)
                    logger.debug('exchange rate created %s/%s=%s'
                                 % (source, target, rate))

            logger.info('exchange rates updated for %s' % source.code)
        logger.info("Updating %s rows" % len(updates))
        update_many(updates)
        logger.info("Inserting %s rows" % len(inserts))
        insert_many(inserts)
        logger.info('saved rates to db')
43301
def get_currencies(self, **params):
        """"""
        response = self._get('v2', 'currencies', params=params)
        return self._make_api_object(response, APIObject)
616182
def get_currencys(self, site='Pro', _async=False):
        
        assert site in ['Pro', 'HADAX']
        params = {}
        path = f'/v1{"/" if site == "Pro" else "/hadax/"}common/currencys'
        return api_key_get(params, path, _async=_async)
1183971
def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
    
    reverse_rate = False
    if to_currency == BASE_CURRENCY:
        # Fetch exchange rate for base currency and use 1 / rate for conversion
        rate_currency = from_currency
        reverse_rate = True
    else:
        rate_currency = to_currency
    rate = get_rate_from_db(rate_currency)

    if reverse_rate:
        conversion_rate = Decimal(1) / rate
    else:
        conversion_rate = rate
    return 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)
327763
def get_type_data(name):
    
    name = name.upper()
    if name in ISO_CURRENCY_TYPES:
        article = 'the '
        type_name = ISO_CURRENCY_TYPES[name]
    elif name in ISO_CURRENCY_ELEMENT_TYPES:
        article = ''
        type_name = ISO_CURRENCY_ELEMENT_TYPES[name]
    else:
        raise NotFound('Currency Type: ' + name)

    return {
        'authority': 'ISO',
        'namespace': '4217',
        'identifier': name,
        'domain': 'ISO Currency Types',
        'display_name': type_name + ' Currency Type',
        'display_label': type_name,
        'description': ('The ISO currency type for ' + article +
                        type_name + '.')
    }
1097405
def convert_using_api(from_currency, to_currency):
	
	convert_str = from_currency + '_' + to_currency
	options = {'compact': 'ultra', 'q': convert_str}
	api_url = 'https://free.currencyconverterapi.com/api/v5/convert'
	result = requests.get(api_url, params=options).json()
	return result[convert_str]