Created
September 3, 2017 07:43
-
-
Save MKtalk/fe2a440218883ef67803f12b125e2a38 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- 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