コード例 #1
0
 def test_bitcoin_multiple_tsyms(self):
     """Requesting multiple price for multiple quote symbols should work"""
     cc = CryptoCompare()
     tsyms = ['USD', 'EUR', 'JPY', 'ETH']
     result = cc.get_price('BTC', tsyms)
     for symbol in tsyms:
         self.assertIn(symbol, result['BTC'].keys())
コード例 #2
0
 def test_multiple_fsyms_and_tsyms(self):
     """Requesting multiple price for multiple base and quote symbols should work"""
     cc = CryptoCompare()
     fsyms = ['BTC', 'LTC', 'ETH']
     tsyms = ['USD', 'EUR']
     result = cc.get_price(fsyms, tsyms)
     for fs in fsyms:
         for ts in tsyms:
             self.assertIn(ts, result[fs])
コード例 #3
0
 def test_bitcoin_usd(self):
     """Request BTC/USD price should return that pair rate"""
     cc = CryptoCompare()
     result = cc.get_price('BTC', 'USD')
     self.assertIsInstance(result['BTC']['USD'], numbers.Real)
コード例 #4
0
 def test_bitcoin_usd_specific_exchange(self):
     """Request BTC/USD price on specific exchange should work"""
     cc = CryptoCompare()
     result = cc.get_price('BTC', 'USD', exchange='Bitstamp')
     self.assertIsInstance(result['BTC']['USD'], numbers.Real)
コード例 #5
0
 def test_bitcoin_lowercase(self):
     """Working with lowercase symbols should work"""
     cc = CryptoCompare()
     result = cc.get_price('btc', 'usd')
     self.assertIsInstance(result['BTC']['USD'], numbers.Real)
コード例 #6
0
from cryptocompare import CryptoCompare

COINS = ['BTC', 'LTC', 'ETH', 'BCH', 'USD', 'EUR']

cc = CryptoCompare()
prices = cc.get_price(COINS, COINS)

print(end='\t')
for coin in COINS:  # top header
    print(coin, end='\t')

for a in COINS:
    print('\n', a, end='\t')  # left header
    for b in COINS:
        print('{:7.2f}'.format(prices[a][b]), end='\t')