metglobal / openexchangerates Goto Github PK
View Code? Open in Web Editor NEWopenexchangerates python API client
License: MIT License
openexchangerates python API client
License: MIT License
The library returns floats at the moment, which may result in loss of accuracy. parse_float=decimal.Decimal
needs to be passed to the JSON decoding somehow.
The code uses the old style of exception handling. It appears that a small change
requests.exceptions.RequestException, e:
to
requests.exceptions.RequestException as e:
on lines 52, 78 and 107 makes the code python 3.4 compatible using the anaconda distribution.
Looks like this package isn't compatible with Django 1.9.
Hello, I find your package to be pretty convenient. However, could you please add a time series endpoint?
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.