Add colorization
This commit is contained in:
parent
c92e1d97d6
commit
e598c769d4
@ -30,9 +30,9 @@ ARGS_HYPEROPT = ARGS_COMMON_OPTIMIZE + ["hyperopt", "hyperopt_path",
|
|||||||
|
|
||||||
ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]
|
ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]
|
||||||
|
|
||||||
ARGS_LIST_STRATEGIES = ["strategy_path", "print_one_column"]
|
ARGS_LIST_STRATEGIES = ["strategy_path", "print_one_column", "print_colorized"]
|
||||||
|
|
||||||
ARGS_LIST_HYPEROPTS = ["hyperopt_path", "print_one_column"]
|
ARGS_LIST_HYPEROPTS = ["hyperopt_path", "print_one_column", "print_colorized"]
|
||||||
|
|
||||||
ARGS_LIST_EXCHANGES = ["print_one_column", "list_exchanges_all"]
|
ARGS_LIST_EXCHANGES = ["print_one_column", "list_exchanges_all"]
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ from collections import OrderedDict
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
from colorama import init as colorama_init
|
||||||
|
from colorama import Fore, Style
|
||||||
import rapidjson
|
import rapidjson
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
|
|
||||||
@ -36,14 +38,23 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
|
|||||||
print(f"Exchanges available for Freqtrade: {', '.join(exchanges)}")
|
print(f"Exchanges available for Freqtrade: {', '.join(exchanges)}")
|
||||||
|
|
||||||
|
|
||||||
def _print_objs_tabular(objs: List) -> None:
|
def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
|
||||||
|
if print_colorized:
|
||||||
|
colorama_init(autoreset=True)
|
||||||
|
|
||||||
names = [s['name'] for s in objs]
|
names = [s['name'] for s in objs]
|
||||||
objss_to_print = [{
|
objss_to_print = [{
|
||||||
'name': s['name'] if s['name'] else "--",
|
'name': s['name'] if s['name'] else "--",
|
||||||
'location': s['location'].name,
|
'location': s['location'].name,
|
||||||
'status': ("LOAD FAILED" if s['class'] is None
|
'status': (((Fore.RED if print_colorized else '') +
|
||||||
else "OK" if names.count(s['name']) == 1
|
"LOAD FAILED" + (Style.RESET_ALL if print_colorized else ''))
|
||||||
else "DUPLICATED NAME")
|
if s['class'] is None
|
||||||
|
else ((Fore.GREEN if print_colorized else '') +
|
||||||
|
"OK" + (Style.RESET_ALL if print_colorized else ''))
|
||||||
|
if names.count(s['name']) == 1
|
||||||
|
else ((Fore.YELLOW if print_colorized else '') +
|
||||||
|
"DUPLICATED NAME" +
|
||||||
|
(Style.RESET_ALL if print_colorized else '')))
|
||||||
} for s in objs]
|
} for s in objs]
|
||||||
|
|
||||||
print(tabulate(objss_to_print, headers='keys', tablefmt='pipe'))
|
print(tabulate(objss_to_print, headers='keys', tablefmt='pipe'))
|
||||||
@ -63,7 +74,7 @@ def start_list_strategies(args: Dict[str, Any]) -> None:
|
|||||||
if args['print_one_column']:
|
if args['print_one_column']:
|
||||||
print('\n'.join([s['name'] for s in strategy_objs]))
|
print('\n'.join([s['name'] for s in strategy_objs]))
|
||||||
else:
|
else:
|
||||||
_print_objs_tabular(strategy_objs)
|
_print_objs_tabular(strategy_objs, config.get('print_colorized', False))
|
||||||
|
|
||||||
|
|
||||||
def start_list_hyperopts(args: Dict[str, Any]) -> None:
|
def start_list_hyperopts(args: Dict[str, Any]) -> None:
|
||||||
@ -82,7 +93,7 @@ def start_list_hyperopts(args: Dict[str, Any]) -> None:
|
|||||||
if args['print_one_column']:
|
if args['print_one_column']:
|
||||||
print('\n'.join([s['name'] for s in hyperopt_objs]))
|
print('\n'.join([s['name'] for s in hyperopt_objs]))
|
||||||
else:
|
else:
|
||||||
_print_objs_tabular(hyperopt_objs)
|
_print_objs_tabular(hyperopt_objs, config.get('print_colorized', False))
|
||||||
|
|
||||||
|
|
||||||
def start_list_timeframes(args: Dict[str, Any]) -> None:
|
def start_list_timeframes(args: Dict[str, Any]) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user