-
Notifications
You must be signed in to change notification settings - Fork 1
/
pairs-by-volume.py
43 lines (34 loc) · 966 Bytes
/
pairs-by-volume.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
""" lists pair names, lowest volume first """
import ccxt
import sys
exchange = sys.argv[-1]
try:
ex = getattr(ccxt, exchange)()
except AttributeError:
print('Specify exchange name as first argument.')
exit()
tickers = ex.fetch_tickers()
# 'ETH/BTC': 102923 (USD), ...
tickers_usd = {}
for symbol, ticker in tickers.items():
quoteCurrency = symbol.split('/')[1]
if quoteCurrency != 'USD' and quoteCurrency != 'USDT':
quoteUsd = quoteCurrency + '/USD'
try:
quotePair = tickers[quoteUsd]
quotePrice = quotePair['last']
except KeyError:
try:
quoteUsd = quoteCurrency + '/USDT'
quotePair = tickers[quoteUsd]
quotePrice = quotePair['last']
except KeyError:
quotePrice = 0
else:
quotePrice = 1
thisPrice = quotePrice * ticker['last']
volumeUsd = thisPrice * ticker['baseVolume']
tickers_usd[symbol] = volumeUsd
tickers_sorted = sorted(tickers_usd, key=tickers_usd.get, reverse=True)
for x in tickers_sorted:
print(x)