1. CryptoCompare
pip3 install cryptocompare
import cryptocompare
price = cryptocompare.get_price('BTC', 'USD')
print(price)
2. Cryptofeed
pip3 install cryptofeed
from cryptofeed import FeedHandler from cryptofeed.exchanges import Coinbasedef nbbo_update(symbol, bid, bid_size, ask, ask_size, bid_feed, ask_feed): print( f'Pair: {symbol} ' + f'Bid Price: {bid:.2f} ' + f'Bid Size: {bid_size:.6f} ' + f'Bid Feed: {bid_feed} ' + f'Ask Price: {ask:.2f} ' + f'Ask Size: {ask_size:.6f} ' + f'Ask Feed: {ask_feed}' )feed = FeedHandler() feed.add_nbbo([Coinbase], ['BTC-USD'], nbbo_update) feed.run()
3. Freqtrade
installation section of the official documentation.
4. CCXT
pip3 install ccxt
import ccxtkraken = ccxt.kraken()for trade in kraken.fetch_trades('BTC/USD'): print( f"date: {trade['datetime']} | " + f"symbol: {trade['symbol']} | " + f"price: {trade['price']} | " + f"amount: {trade['amount']} | " + f"cost: {trade['cost']} | " + f"side: {trade['side']} | " + f"type: {trade['type']}" )
CryptoCompare 라이브러리를 이용, 몇개 코인을 USD, KRW으로 60초마다 가져와서 표시하는 간단하게 만들어봤습니다.
윈도우나 리눅스에서 작은 창으로 귀퉁이에 놓으면 좋을듯.ㅎㅎ
import cryptocompare
import time
import os
while 1:
BTC = cryptocompare.get_price('BTC', ['USD', 'KRW'])
ETH = cryptocompare.get_price('ETH', ['USD', 'KRW'])
ETC = cryptocompare.get_price('ETC', ['USD', 'KRW'])
RVN = cryptocompare.get_price('RVN', ['USD', 'KRW'])
CLO = cryptocompare.get_price('CLO', ['USD', 'KRW'])
BTG = cryptocompare.get_price('BTG', ['USD', 'KRW'])
XMR = cryptocompare.get_price('XMR', ['USD', 'KRW'])
if os.name == 'nt':
_=os.system('cls')
else:
_=os.system('clear')
print('================================================')
print(' Coin : USD, KRW value ')
print('================================================')
print(BTC)
print(ETH)
print(ETC)
print(RVN)
print(CLO)
print(BTG)
print(XMR)
print()
time.sleep(60)
pass