Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------
Expand Down
1 change: 1 addition & 0 deletions hackr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from . import image
from . import iptools
from . import crypto
from . import converter
14 changes: 14 additions & 0 deletions hackr/converter.py
Original file line number Diff line number Diff line change
@@ -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'