From 2e79aaae0023635d24ec6016978dcf6aca113d9d Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 20 May 2023 11:02:13 +0200 Subject: [PATCH] Remove usage of args. It's clumsy to use and prevents specifying settings in the configuration. --- freqtrade/commands/optimize_commands.py | 11 ++++------- freqtrade/optimize/lookahead_analysis.py | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/freqtrade/commands/optimize_commands.py b/freqtrade/commands/optimize_commands.py index 78ad140de..866bf8e61 100644 --- a/freqtrade/commands/optimize_commands.py +++ b/freqtrade/commands/optimize_commands.py @@ -144,7 +144,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None: """ config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) - if args['targeted_trade_amount'] < args['minimum_trade_amount']: + if config['targeted_trade_amount'] < config['minimum_trade_amount']: # add logic that tells the user to check the configuration # since this combo doesn't make any sense. pass @@ -153,13 +153,10 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None: config, enum_failed=False, recursive=config.get('recursive_strategy_search', False)) lookaheadAnalysis_instances = [] - strategy_list = [] # unify --strategy and --strategy_list to one list - if 'strategy' in args and args['strategy'] is not None: - strategy_list = [args['strategy']] - else: - strategy_list = args['strategy_list'] + if not (strategy_list := config.get('strategy_list', [])): + strategy_list = [config['strategy']] # check if strategies can be properly loaded, only check them if they can be. if strategy_list is not None: @@ -168,7 +165,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None: if strategy_obj['name'] == strat and strategy_obj not in strategy_list: lookaheadAnalysis_instances.append( LookaheadAnalysisSubFunctions.initialize_single_lookahead_analysis( - strategy_obj, config, args)) + strategy_obj, config)) break # report the results diff --git a/freqtrade/optimize/lookahead_analysis.py b/freqtrade/optimize/lookahead_analysis.py index 8e6771b4b..90aa934a6 100755 --- a/freqtrade/optimize/lookahead_analysis.py +++ b/freqtrade/optimize/lookahead_analysis.py @@ -42,7 +42,7 @@ class Analysis: class LookaheadAnalysis: - def __init__(self, config: Dict[str, Any], strategy_obj: dict, args: Dict[str, Any]): + def __init__(self, config: Dict[str, Any], strategy_obj: Dict): self.failed_bias_check = True self.full_varHolder = VarHolder @@ -53,9 +53,9 @@ class LookaheadAnalysis: self.local_config = deepcopy(config) self.local_config['strategy'] = strategy_obj['name'] self.current_analysis = Analysis() - self.minimum_trade_amount = args['minimum_trade_amount'] - self.targeted_trade_amount = args['targeted_trade_amount'] - self.exportfilename = args['exportfilename'] + self.minimum_trade_amount = config['minimum_trade_amount'] + self.targeted_trade_amount = config['targeted_trade_amount'] + self.exportfilename = config['exportfilename'] self.strategy_obj = strategy_obj @staticmethod @@ -339,12 +339,11 @@ class LookaheadAnalysisSubFunctions: csv_df.to_csv(config['lookahead_analysis_exportfilename'], index=False) @staticmethod - def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any], - args: Dict[str, Any]): + def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any]): logger.info(f"Bias test of {Path(strategy_obj['location']).name} started.") start = time.perf_counter() - current_instance = LookaheadAnalysis(config, strategy_obj, args) + current_instance = LookaheadAnalysis(config, strategy_obj) current_instance.start() elapsed = time.perf_counter() - start logger.info(f"checking look ahead bias via backtests "