Restore get_market_pairs from develop

This commit is contained in:
Matthias 2019-04-19 06:43:12 +02:00
parent f03acce84c
commit 72657758d5

View File

@ -1,7 +1,10 @@
"""
This script was adapted from ccxt here:
https://github.com/ccxt/ccxt/blob/master/examples/py/arbitrage-pairs.py
"""
import os import os
import sys import sys
import traceback
from freqtrade.exchange import is_exchange_supported, supported_exchanges
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python') sys.path.append(root + '/python')
@ -46,15 +49,22 @@ def dump(*args):
def print_supported_exchanges(): def print_supported_exchanges():
dump('Supported exchanges:', green(', '.join(supported_exchanges()))) dump('Supported exchanges:', green(', '.join(ccxt.exchanges)))
try: try:
if len(sys.argv) < 2:
dump("Usage: python " + sys.argv[0], green('id'))
print_supported_exchanges()
sys.exit(1)
id = sys.argv[1] # get exchange id from command line arguments id = sys.argv[1] # get exchange id from command line arguments
# check if the exchange is supported by ccxt # check if the exchange is supported by ccxt
if is_exchange_supported(id): exchange_found = id in ccxt.exchanges
if exchange_found:
dump('Instantiating', green(id), 'exchange') dump('Instantiating', green(id), 'exchange')
# instantiate the exchange by id # instantiate the exchange by id
@ -79,11 +89,15 @@ try:
for (k, v) in tuples: for (k, v) in tuples:
dump('{:<15} {:<15} {:<15} {:<15}'.format(v['id'], v['symbol'], v['base'], v['quote'])) dump('{:<15} {:<15} {:<15} {:<15}'.format(v['id'], v['symbol'], v['base'], v['quote']))
else: else:
dump('Exchange ' + red(id) + ' not found') dump('Exchange ' + red(id) + ' not found')
print_supported_exchanges() print_supported_exchanges()
except Exception as e: except Exception as e:
dump('[' + type(e).__name__ + ']', str(e)) dump('[' + type(e).__name__ + ']', str(e))
dump(traceback.format_exc())
dump("Usage: python " + sys.argv[0], green('id')) dump("Usage: python " + sys.argv[0], green('id'))
print_supported_exchanges() print_supported_exchanges()
sys.exit(1)