diff --git a/freqtrade/commands/__init__.py b/freqtrade/commands/__init__.py index ec145eb5f..969b8df09 100644 --- a/freqtrade/commands/__init__.py +++ b/freqtrade/commands/__init__.py @@ -27,6 +27,7 @@ from freqtrade.commands.hyperopt_commands import start_hyperopt_list, start_hype from freqtrade.commands.list_commands import ( start_list_exchanges, start_list_freqAI_models, + start_list_hyperopt_loss_functions, start_list_markets, start_list_strategies, start_list_timeframes, diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index a7b65f079..0bb572ebc 100755 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -258,6 +258,7 @@ NO_CONF_REQURIED = [ "list-pairs", "list-strategies", "list-freqaimodels", + "list-hyperoptloss", "list-data", "hyperopt-list", "hyperopt-show", @@ -365,6 +366,7 @@ class Arguments: start_list_data, start_list_exchanges, start_list_freqAI_models, + start_list_hyperopt_loss_functions, start_list_markets, start_list_strategies, start_list_timeframes, @@ -566,6 +568,15 @@ class Arguments: list_strategies_cmd.set_defaults(func=start_list_strategies) self._build_args(optionlist=ARGS_LIST_STRATEGIES, parser=list_strategies_cmd) + # Add list-Hyperopt loss subcommand + list_hyperopt_loss_cmd = subparsers.add_parser( + "list-hyperoptloss", + help="Print available hyperopt loss functions.", + parents=[_common_parser], + ) + list_hyperopt_loss_cmd.set_defaults(func=start_list_hyperopt_loss_functions) + self._build_args(optionlist=ARGS_LIST_HYPEROPTS, parser=list_hyperopt_loss_cmd) + # Add list-freqAI Models subcommand list_freqaimodels_cmd = subparsers.add_parser( "list-freqaimodels", diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py index c59412d8a..0279f82ee 100644 --- a/freqtrade/commands/list_commands.py +++ b/freqtrade/commands/list_commands.py @@ -169,6 +169,24 @@ def start_list_freqAI_models(args: dict[str, Any]) -> None: _print_objs_tabular(model_objs, config.get("print_colorized", False)) +def start_list_hyperopt_loss_functions(args: dict[str, Any]) -> None: + """ + Print files with FreqAI models custom classes available in the directory + """ + from freqtrade.configuration import setup_utils_configuration + from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver + + config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) + + model_objs = HyperOptLossResolver.search_all_objects(config, not args["print_one_column"]) + # Sort alphabetically + model_objs = sorted(model_objs, key=lambda x: x["name"]) + if args["print_one_column"]: + print("\n".join([s["name"] for s in model_objs])) + else: + _print_objs_tabular(model_objs, config.get("print_colorized", False)) + + def start_list_timeframes(args: dict[str, Any]) -> None: """ Print timeframes available on Exchange