Skip to content

Instantly share code, notes, and snippets.

@MKtalk
Created September 3, 2017 07:43
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 MKtalk/fe2a440218883ef67803f12b125e2a38 to your computer and use it in GitHub Desktop.
Save MKtalk/fe2a440218883ef67803f12b125e2a38 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import requests
from datetime import datetime
def coin_detail(coin):
base_url = 'https://api.bitfinex.com/v1/pubticker/'
url = '{}{}'.format(base_url, coin)
response = requests.get(url)
msg = message(response.json())
return msg
def message(data):
last_price = float(data.get('last_price'))
high_price = float(data.get('high'))
low_price = float(data.get('low'))
bid_price = float(data.get('bid'))
ask_price = float(data.get('ask'))
timestamp = datetime.fromtimestamp(float(data.get('timestamp')))
return '''
Last order price: {:,}
Highest trade price of the last 24 hours: {:,}
Lowest trade price of the last 24 hours: {:,}
Innermost bid: {:,}
Innermost ask: {:,}
Timestamp: {}
'''.format(last_price, high_price, low_price, bid_price, ask_price, timestamp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment