Skip to content

Commit 25bf07f

Browse files
committed
Fixed for binance and coingecko
1 parent 45967cf commit 25bf07f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
setup(name='get_crypto_price',
5-
version='0.2.0',
5+
version='0.2.1',
66
description="""A library to getting crypto price.""",
77
long_description="""
88
# Get Crypto Price

src/get_crypto_price/get_crypto_price.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ def get_crypto_price(source = "bitstamp", crypto = "btc", pair = "usdt"):
2626

2727
try:
2828
r = requests.get(URL)
29-
priceFloat = float(json.loads(r.text)["last"])
29+
print(r.text)
30+
if source == "bitstamp":
31+
priceFloat = float(json.loads(r.text)["last"])
32+
elif source == "binance":
33+
priceFloat = float(json.loads(r.text)["price"])
34+
elif source == "coingecko":
35+
priceFloat = float(json.loads(r.text)[crypto][pair])
3036
return priceFloat
3137

3238
except requests.ConnectionError:

0 commit comments

Comments
 (0)