Skip to content

Commit

Permalink
Disable duplicate (crypto)currency symbols #32
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Nov 21, 2017
1 parent 1992f9f commit f294c71
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
Binary file not shown.
28 changes: 14 additions & 14 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
u'BOV': u'Bolivian Mvdol',
u'BRL': u'Brazilian real',
u'BSD': u'Bahamian dollar',
u'BTC': u'Bitcoin',
# u'BTC': u'Bitcoin',
u'BTN': u'Bhutanese ngultrum',
u'BWP': u'Botswana pula',
u'BYN': u'Belarusian ruble',
Expand Down Expand Up @@ -229,12 +229,12 @@
u'XAU': u'Gold (one troy ounce)',
u'XBA': u'European Composite Unit (EURCO)',
u'XBB': u'European Monetary Unit (E.M.U.-6)',
u'XBC': u'European Unit of Account 9 (E.U.A.-9)',
# u'XBC': u'European Unit of Account 9 (E.U.A.-9)',
u'XBD': u'European Unit of Account 17 (E.U.A.-17)',
u'XCD': u'East Caribbean dollar',
u'XDR': u'Special drawing rights',
u'XOF': u'CFA franc BCEAO',
u'XPD': u'Palladium (one troy ounce)',
# u'XPD': u'Palladium (one troy ounce)',
u'XPF': u'CFP franc (franc Pacifique)',
u'XPT': u'Platinum (one troy ounce)',
u'XSU': u'SUCRE',
Expand Down Expand Up @@ -402,7 +402,7 @@
u'BNT': u'Bancor Network Token',
u'BNX': u'BnrtxCoin',
u'BOAT': u'Doubloon',
u'BOB': u'Bob Coin',
# u'BOB': u'Bob Coin',
u'BOLI': u'BolivarCoin',
u'BOMB': u'BombCoin',
u'BON': u'BonesCoin',
Expand All @@ -424,7 +424,7 @@
u'BRX': u'Breakout Stake',
u'BS': u'BlackShadowCoin',
u'BSC': u'BowsCoin',
u'BSD': u'BitSend',
# u'BSD': u'BitSend',
u'BST': u'BitStone',
u'BSTAR': u'Blackstar',
u'BSTK': u'BattleStake',
Expand Down Expand Up @@ -524,7 +524,7 @@
u'CNL': u'ConcealCoin',
u'CNMT': u'Coinomat',
u'CNO': u'Coino',
u'CNT': u'Centurion',
# u'CNT': u'Centurion',
u'CNX': u'Cryptonex',
u'COB': u'Cobinhood',
u'COC': u'Community Coin',
Expand All @@ -550,7 +550,7 @@
u'CRAIG': u'CraigsCoin',
u'CRAVE': u'CraveCoin',
u'CRBIT': u'Creditbit ',
u'CRC': u'CraftCoin',
# u'CRC': u'CraftCoin',
u'CRE': u'Credits',
u'CREA': u'CreativeChain',
u'CREVA': u'Creva Coin',
Expand Down Expand Up @@ -802,7 +802,7 @@
u'GGS': u'Gilgam',
u'GHC': u'GhostCoin',
u'GHOUL': u'Ghoul Coin',
u'GHS': u'Giga Hash',
# u'GHS': u'Giga Hash',
u'GIFT': u'GiftNet',
u'GIG': u'GigCoin',
u'GIM': u'Gimli',
Expand Down Expand Up @@ -1024,7 +1024,7 @@
u'LYC': u'LycanCoin',
u'M1': u'SupplyShock',
u'MAC': u'MachineCoin',
u'MAD': u'SatoshiMadness',
# u'MAD': u'SatoshiMadness',
u'MAID': u'MaidSafe Coin',
u'MANA': u'Decentraland',
u'MAPC': u'MapCoin',
Expand Down Expand Up @@ -1220,7 +1220,7 @@
u'PCS': u'Pabyosi Coin',
u'PDC': u'Project Decorum',
u'PEC': u'PeaceCoin',
u'PEN': u'PenCoin',
# u'PEN': u'PenCoin',
u'PEPECASH': u'Pepe Cash',
u'PEX': u'PosEx',
u'PGL': u'Prospectors',
Expand Down Expand Up @@ -1361,10 +1361,10 @@
u'SAN': u'Santiment',
u'SAND': u'BeachCoin',
u'SANDG': u'Save and Gain',
u'SAR': u'SARCoin',
# u'SAR': u'SARCoin',
u'SAT2': u'Saturn2Coin',
u'SBC': u'StableCoin',
u'SBD': u'Steem Backed Dollars',
# u'SBD': u'Steem Backed Dollars',
u'SC': u'Siacoin',
u'SCASH': u'SpaceCash',
u'SCL': u'Social Nexus',
Expand Down Expand Up @@ -1401,7 +1401,7 @@
u'SLING': u'Sling Coin',
u'SLM': u'SlimCoin',
u'SLR': u'SolarCoin',
u'SLS': u'SaluS',
# u'SLS': u'SaluS',
u'SMAC': u'Social Media Coin',
u'SMART': u'SmartCash',
u'SMC': u'SmartCoin',
Expand Down Expand Up @@ -1636,7 +1636,7 @@
u'WTT': u'Giga Watt',
u'X2': u'X2Coin',
u'XAI': u'SapienceCoin',
u'XAU': u'XauCoin',
# u'XAU': u'XauCoin',
u'XAUR': u'Xaurum',
u'XBC': u'BitcoinPlus',
u'XBOT': u'SocialXbotCoin',
Expand Down
4 changes: 2 additions & 2 deletions src/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ def register_exchange_rates(exchange_rates):
exchange_rates (dict): `{symbol: rate}` mapping of currencies.
"""
# EUR will be the baseline currency. All exchange rates are
# defined relative to the euro
# USD will be the baseline currency. All exchange rates are
# defined relative to the US dollar
ureg.define('USD = [currency] = usd')

for abbr, rate in exchange_rates.items():
Expand Down
18 changes: 16 additions & 2 deletions src/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ def load_cryptocurrency_rates(symbols):
"""
url = CRYPTO_COMPARE_BASE_URL.format(REFERENCE_CURRENCY, ','.join(symbols))

log.debug('fetching %s ...', url)
r = web.get(url, headers={'User-Agent': USER_AGENT})
r.raise_for_status()

data = r.json()
log.debug('fetching %s ...', url)
for sym, rate in data.items():
log.debug('[CryptoCompare.com] 1 %s = %s %s',
REFERENCE_CURRENCY, rate, sym)

return data


Expand Down Expand Up @@ -126,6 +130,8 @@ def load_openx_rates(symbols):
for sym, rate in data['rates'].items():
if sym not in wanted:
continue
log.debug('[OpenExchangeRates.org] 1 %s = %s %s',
REFERENCE_CURRENCY, rate, sym)
rates[sym] = rate

return rates
Expand Down Expand Up @@ -173,7 +179,15 @@ def fetch_exchange_rates():
# rates.update(load_openx_rates(syms))
jobs = [(load_openx_rates, (syms,))]

syms = [s for s in CRYPTO_CURRENCIES.keys() if s in active]
syms = []
for s in CRYPTO_CURRENCIES.keys():
if s in CURRENCIES:
log.warning('ignoring crytopcurrency "%s", as it conflicts with '
'a fiat currency', s)
continue
if s in active:
syms.append(s)
# syms = [s for s in CRYPTO_CURRENCIES.keys() if s in active]
for symbols in grouper(SYMBOLS_PER_REQUEST, syms):
jobs.append((load_cryptocurrency_rates, (symbols,)))

Expand Down
2 changes: 1 addition & 1 deletion src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ UPDATE_INTERVAL is the number of minutes between exchange rate updates.</string>
<string>APP_KEY</string>
</array>
<key>version</key>
<string>3.3</string>
<string>3.3.1</string>
<key>webaddress</key>
<string></string>
</dict>
Expand Down

0 comments on commit f294c71

Please sign in to comment.