Skip to content

Instantly share code, notes, and snippets.

@MKtalk
Created September 3, 2017 07:10
Show Gist options
  • Save MKtalk/a160116e35abf3bb32fff4aa664ce6b0 to your computer and use it in GitHub Desktop.
Save MKtalk/a160116e35abf3bb32fff4aa664ce6b0 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.korbit.co.kr/v1/ticker/detailed'
url = '{}?currency_pair={}'.format(base_url, coin)
response = requests.get(url)
msg = message(response.json())
return msg
def message(data):
last_price = int(data.get('last'))
high_price = int(data.get('high'))
low_price = int(data.get('low'))
bid_price = int(data.get('bid'))
ask_price = int(data.get('ask'))
timestamp = datetime.fromtimestamp(int(data.get('timestamp')/1000))
return '''
KORBIT 현재가: {:,}
최근 24시간 최고가: {:,}
최근 24시간 최저가: {:,}
매수 호가: {:,}
매도 호가: {:,}
최종 체결 시각: {}
'''.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