mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Update list_exchanges to use a dict internally
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user