diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py index 3358f8cc8..d81800896 100644 --- a/freqtrade/commands/list_commands.py +++ b/freqtrade/commands/list_commands.py @@ -28,15 +28,20 @@ def start_list_exchanges(args: Dict[str, Any]) -> None: exchanges = validate_exchanges(args['list_exchanges_all']) if args['print_one_column']: - print('\n'.join([e[0] for e in exchanges])) + print('\n'.join([e['name'] for e in exchanges])) else: if args['list_exchanges_all']: print("All exchanges supported by the ccxt library:") else: print("Exchanges available for Freqtrade:") - exchanges = [e for e in exchanges if e[1] is not False] + exchanges = [e for e in exchanges if e['valid'] is not False] - print(tabulate(exchanges, headers=['Exchange name', 'Valid', 'reason'])) + headers = { + 'name': 'Exchange name', + 'valid': 'Valid', + 'comment': 'reason', + } + print(tabulate(exchanges, headers=headers)) def _print_objs_tabular(objs: List, print_colorized: bool) -> None: diff --git a/freqtrade/exchange/exchange_utils.py b/freqtrade/exchange/exchange_utils.py index c6c2d5a24..32a68a959 100644 --- a/freqtrade/exchange/exchange_utils.py +++ b/freqtrade/exchange/exchange_utils.py @@ -10,6 +10,7 @@ from ccxt import (DECIMAL_PLACES, ROUND, ROUND_DOWN, ROUND_UP, SIGNIFICANT_DIGIT TRUNCATE, decimal_to_precision) from freqtrade.exchange.common import BAD_EXCHANGES, EXCHANGE_HAS_OPTIONAL, EXCHANGE_HAS_REQUIRED +from freqtrade.exchange.types import ValidExchangesType from freqtrade.util import FtPrecise from freqtrade.util.datetime_helpers import dt_from_ts, dt_ts @@ -55,14 +56,17 @@ def validate_exchange(exchange: str) -> Tuple[bool, str]: return True, '' -def validate_exchanges(all_exchanges: bool) -> List[Tuple[str, bool, str]]: +def validate_exchanges(all_exchanges: bool) -> List[ValidExchangesType]: """ :return: List of tuples with exchangename, valid, reason. """ exchanges = ccxt_exchanges() if all_exchanges else available_exchanges() - exchanges_valid = [ - (e, *validate_exchange(e)) for e in exchanges + + exchanges_valid: List[ValidExchangesType] = [ + {'name': e, 'valid': valid, 'comment': comment} + for e, valid, comment in ((e, *validate_exchange(e)) for e in exchanges) ] + return exchanges_valid diff --git a/freqtrade/exchange/types.py b/freqtrade/exchange/types.py index 5568e4336..b20c51201 100644 --- a/freqtrade/exchange/types.py +++ b/freqtrade/exchange/types.py @@ -26,5 +26,13 @@ class OrderBook(TypedDict): Tickers = Dict[str, Ticker] + +# Used for list-exchanges +class ValidExchangesType(TypedDict): + name: str + valid: bool + comment: str + + # pair, timeframe, candleType, OHLCV, drop last?, OHLCVResponse = Tuple[str, str, CandleType, List, bool]