Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError caused by nonexistent currency #10

Open
forgingdestiny opened this issue Jul 19, 2017 · 0 comments
Open

KeyError caused by nonexistent currency #10

forgingdestiny opened this issue Jul 19, 2017 · 0 comments

Comments

@forgingdestiny
Copy link

Getting a KeyError on exchange.tasks.update_task

Here's the info about the exception:

KeyError 'EEK'

exchange/adapters/__init__.py in _get_rate_through_usd at line 70
    
def _get_rate_through_usd(self, source, target, usd_rates):
        # from: https://openexchangerates.org/documentation#how-to-use
        # gbp_hkd = usd_hkd * (1 / usd_gbp)
        usd_source = usd_rates[source]
        usd_target = usd_rates[target]
        rate = usd_target * (Decimal(1.0) / usd_source)
        rate = rate.quantize(Decimal('0.123456'))  # round to 6 decimal places
        return rate
self <exchange.adapters.openexchangerates.OpenExchangeRatesAdapter object at 0x7f23d0dbed10>
source u'ZWL'
target u'EEK'
usd_rates {u'BBD': Decimal('2'), u'BIF': Decimal('1725.5'), u'BMD': Decimal('1'), u'BRL': Decimal('3.153503'), u'BSD': Decimal('1'), u'BZD': Decimal('2.015409'), u'CAD': Decimal('1.259755'), u'CVE': Decimal('95.6'), u'EGP': Decimal('17.9477'), u'GHS': Decimal('4.395'), u'GNF': Decimal('9000'), u'GYD': Decimal('207.98'), u'HNL': Decimal('23.46'), u'JEP': Decimal('0.766716'), u'JMD': Decimal('127.82'), u'KHR': Decimal('4101'), u'KPW': Decimal('900.09'), u'MXN': Decimal('17.504933'), u'MZN': Decimal('60.994761'), u'PKR': Decimal('105.25'), u'PYG': Decimal('5550.8'), u'RON': Decimal('3.96905'), u'SCR': Decimal('13.424847'), u'SSP': Decimal('124.6179'), u'UYU': Decimal('28.645625'), u'VND': Decimal('22723.99374'), u'XAU': Decimal('0...., u'ZWL': Decimal('322.322775')}
usd_source Decimal('322.322775')

After further investigation, getting a 400 when getting EEK rates too.

get_exchangerates('EEK')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/app/.heroku/src/django-exchange/exchange/adapters/openexchangerates.py", line 29, in get_exchangerates
    return self.client.latest(base)['rates'].items()
  File "/app/.heroku/python/lib/python2.7/site-packages/openexchangerates/__init__.py", line 52, in latest
    raise OpenExchangeRatesClientException(e)
OpenExchangeRatesClientException: 400 Client Error: Bad Request for url: http://openexchangerates.org/api/latest.json?app_id=xxxxxxxxxxxxxxxxx&base=EEK

I obscured the app_id.

Shouldn't this be caught in some way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant