Last active
August 24, 2017 07:15
-
-
Save MiloDavis/ddd69932af7e9ec7b941c121119f03a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import json | |
from forex_python.bitcoin import BtcConverter | |
def get_price(symbol): | |
currency = json.loads(requests.get("https://coinmarketcap-nexuist.rhcloud.com/api/" + symbol).text) | |
return currency['price']['usd'] | |
b = BtcConverter() | |
btc_price = b.get_latest_price('USD') | |
r = requests.get("https://check.tezos.com/stats.json") | |
data = json.loads(r.text) | |
btc = int(data['satoshis']) / 100000000.0 | |
btc_contrib = btc * btc_price | |
bch_price = get_price("bch") | |
bch_contrib = btc * bch_price | |
eth = int(float(data['wei'])) / 1000000000000000000.0 | |
eth_price = get_price("eth") | |
eth_contrib = eth * eth_price | |
total_contrib = btc_contrib + bch_contrib + eth_contrib | |
print "BTC\t{:,d}\t{}\t${:,.2f}".format(int(btc), btc_price, btc_contrib) | |
print "BCH\t{:,d}\t{}\t${:,.2f}".format(int(btc), bch_price, bch_contrib) | |
print "ETH\t{:,d}\t{}\t${:,.2f}".format(int(eth), eth_price, eth_contrib) | |
print "USD\t-\t-\t${:,.2f}".format(int(total_contrib)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Just needed to
pip install forex-python
and it worked great.