Skip to content

Instantly share code, notes, and snippets.

@miljkovicivan
Last active May 18, 2018 10:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miljkovicivan/241e6f84d147db65e523c3aac972138b to your computer and use it in GitHub Desktop.
Save miljkovicivan/241e6f84d147db65e523c3aac972138b to your computer and use it in GitHub Desktop.
IOTA price
import requests
import json
TOTAL = ... # total amount of IOTA
BUY_PRICE = ... # buy price in BTC
def print_stats():
iota_response = requests.get('https://api.bitfinex.com/v2/ticker/tIOTBTC')
if iota_response.status_code == 200:
bid_index = 0
iota_rate = json.loads(iota_response.content)[bid_index]
percentage_profit = 100 * iota_rate / BUY_PRICE - 100
print('Profit: %.2f' % (percentage_profit) + '%')
print(f'Total: %.8f BTC' % (TOTAL * iota_rate))
usd_response = requests.get('https://api.bitfinex.com/v2/ticker/tIOTUSD')
if usd_response.status_code != 200:
print(usd_response.content)
return
iota_rate_usd = json.loads(usd_response.content)[bid_index]
print('Total: $%.2f' % (TOTAL * iota_rate_usd))
else:
print(iota_response.content)
print_stats()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment