Hello world!

Cryptocurrency

김프 값 구하기(Python)

xyz1 2022. 4. 16. 23:24

김프란 김치 프리미엄의 줄임말로써 해외거래소와 한국거래소의 시세차이를 뜻합니다.

import requests
from bs4 import BeautifulSoup
import ccxt

#get dollar value
url = 'https://coinmarketcap.com/ko/currencies/tether'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
select = soup.select('#__next > div.bywovg-1.fUzJes > div.main-content > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div.sc-16r8icm-0.eMxKgr.container > div.n78udj-0.jskEGI > div > div.sc-16r8icm-0.kjciSH.priceSection > div.sc-16r8icm-0.kjciSH.priceTitle > div > span')
Tether_krw = float(str(select[0]).split('₩')[1].split('<')[0].replace(',',''))

#get bitcoin price
binance = ccxt.binance()
upbit = ccxt.upbit()
binance_today_USDT_BTC = binance.fetchTicker('BTC/USDT').get('last')
upbit_today_KRW_BTC = upbit.fetchTicker('BTC/KRW').get('last')
upbit_today_USDT_BTC = upbit_today_KRW_BTC/Tether_krw

#get kimchi premium
kimchi_premium_BTC = str(round((round(upbit_today_USDT_BTC/binance_today_USDT_BTC,4) - 1 )*100, 4)) + '%'
print(kimchi_premium_BTC)


1.08%

github: https://github.com/9521ljh/Cryptocurrency

'Cryptocurrency' 카테고리의 다른 글

Binance 자동매매 만들어드립니다.  (0) 2022.07.12
업비트 자동매매(python) 만들어드립니다.  (0) 2022.06.02
Hash rate(Python)  (0) 2022.04.16
Fear and greed(Python)  (0) 2022.04.16