mirror of
https://github.com/kennethreitz/coinbin.org.git
synced 2026-06-05 23:10:17 +00:00
@@ -12,3 +12,5 @@ pyquery = "*"
|
||||
pandas = "*"
|
||||
html5lib = "*"
|
||||
bs4 = "*"
|
||||
requests = "*"
|
||||
simplejson = "*"
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@ from pyquery import PyQuery as pq
|
||||
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
from decimal import Decimal
|
||||
|
||||
url = 'https://coinmarketcap.com/currencies/views/all/'
|
||||
session = requests.Session()
|
||||
@@ -73,7 +74,7 @@ class Coin():
|
||||
def btc(self):
|
||||
coins = get_coins()
|
||||
rate = coins['btc']['usd']
|
||||
return float(self.usd / rate)
|
||||
return Decimal("{0:.8f}".format(self.usd / rate))
|
||||
|
||||
def value(self, coin):
|
||||
"""Example: BTC -> ETH"""
|
||||
@@ -100,7 +101,7 @@ def get_coins():
|
||||
name = row[2]
|
||||
ticker = row[3].lower()
|
||||
usd = float(row[5][1:].replace(',', ''))
|
||||
btc = usd / btc_value
|
||||
btc = Decimal("{0:.8f}".format(usd / btc_value))
|
||||
|
||||
coins_db.update({ticker: {'rank': rank, 'name': name, 'ticker': ticker, 'usd': usd, 'btc': btc}})
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ def get_exchange_value(coin1, coin2, n):
|
||||
return jsonify(coin={
|
||||
# 'name': c.name,
|
||||
# 'ticker': c.ticker,
|
||||
'value': v * n,
|
||||
'value': float(v) * n,
|
||||
'value.coin': coin2,
|
||||
'exchange_rate': v
|
||||
})
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
{
|
||||
"coins": [{% for coin in coins %}
|
||||
"<strong><a href="/{{ coin['ticker'] }}">{{ coin['ticker'] }}</a></strong>":
|
||||
{{ coin }},{% endfor %}
|
||||
{{ coin|tojson }},{% endfor %}
|
||||
]
|
||||
}
|
||||
</pre>
|
||||
|
||||
Reference in New Issue
Block a user