diff --git a/README.rst b/README.rst index 545d097..984307c 100644 --- a/README.rst +++ b/README.rst @@ -125,22 +125,16 @@ Cryptography >>> d.sha1() hackr + + Cryptocurrencies .. code:: python - >>> import hackr - >>> hackr.crypto.Currency(1).convert('btc','eth') - 32.16 - >>> c = hackr.crypto.Currency(1) - >>> c.convert('btc','eth') - 32.16 - >>> c.coin = 'btc' - >>> c.to('eth') - 32.16 - >>> c.value = 2 - >>> c.to('eth') - 64.32 +Converter + import hackr + hackr.converter.cryptoPricePair('USD','BTC') + 0.0001785 Contribution Guidelines ----------------------- diff --git a/hackr/__init__.py b/hackr/__init__.py index e65a7f9..2d26055 100644 --- a/hackr/__init__.py +++ b/hackr/__init__.py @@ -9,3 +9,4 @@ from . import image from . import iptools from . import crypto +from . import converter diff --git a/hackr/converter.py b/hackr/converter.py new file mode 100644 index 0000000..340b688 --- /dev/null +++ b/hackr/converter.py @@ -0,0 +1,14 @@ +import requests +import json + +""" + +Provides Pricing information on a crypto pair or currency pair, such as USD, BTC, ETH EUR + +""" +def cryptoPricePair(coinA, coinB): + try: + res = json.loads(requests.get('https://min-api.cryptocompare.com/data/price?fsym=%s&tsyms=%s'%(coinA.upper(),coinB.upper())).text) + return str(res[coinB.upper()]) + except Exception as _: + print 'Could not get live IP address'