From e89609dc3a9fc32003243785c9a2e173a4ebd09d Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 2 Jan 2023 08:51:54 +0100 Subject: [PATCH 1/4] Fix crash due to invalid parameter --- freqtrade/strategy/strategyupdater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/strategy/strategyupdater.py b/freqtrade/strategy/strategyupdater.py index 1a0423076..ab757e0a9 100644 --- a/freqtrade/strategy/strategyupdater.py +++ b/freqtrade/strategy/strategyupdater.py @@ -81,7 +81,7 @@ class StrategyUpdater: tree = ast.parse(code) # use the AST to update the code - updated_code = self.modify_ast(self, tree) + updated_code = self.modify_ast(tree) # return the modified code without executing it return updated_code From a712c5d42c567751be0949a2202f48d138547c25 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 2 Jan 2023 08:44:00 +0100 Subject: [PATCH 2/4] Improve if formatting --- freqtrade/strategy/strategyupdater.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/freqtrade/strategy/strategyupdater.py b/freqtrade/strategy/strategyupdater.py index ab757e0a9..a0547932c 100644 --- a/freqtrade/strategy/strategyupdater.py +++ b/freqtrade/strategy/strategyupdater.py @@ -184,9 +184,11 @@ class NameUpdater(ast.NodeTransformer): def visit_Attribute(self, node): # if the attribute name is 'nr_of_successful_buys', # update it to 'nr_of_successful_entries' - if isinstance(node.value, ast.Name) and \ - node.value.id == 'trades' and \ - node.attr == 'nr_of_successful_buys': + if ( + isinstance(node.value, ast.Name) + and node.value.id == 'trades' + and node.attr == 'nr_of_successful_buys' + ): node.attr = 'nr_of_successful_entries' return self.generic_visit(node) @@ -208,9 +210,11 @@ class NameUpdater(ast.NodeTransformer): # otherwise, update its value to 3 else: for child in node.body: - if isinstance(child, ast.Assign) and \ - isinstance(child.targets[0], ast.Name) and \ - child.targets[0].id == 'INTERFACE_VERSION': + if ( + isinstance(child, ast.Assign) + and isinstance(child.targets[0], ast.Name) + and child.targets[0].id == 'INTERFACE_VERSION' + ): child.value = ast.parse('3').body[0].value return self.generic_visit(node) @@ -253,8 +257,6 @@ class NameUpdater(ast.NodeTransformer): def visit_Constant(self, node): # do not update the names in import statements - if node.value in \ - StrategyUpdater.otif_ot_unfilledtimeout: - node.value = \ - StrategyUpdater.otif_ot_unfilledtimeout[node.value] + if node.value in StrategyUpdater.otif_ot_unfilledtimeout: + node.value = StrategyUpdater.otif_ot_unfilledtimeout[node.value] return node From df25dbc048594870d6e5c9356575b47326d8ddef Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 2 Jan 2023 08:52:18 +0100 Subject: [PATCH 3/4] Don't require a configuration for strategy-updater --- freqtrade/commands/arguments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index 9990ad230..a3cdc378a 100644 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -111,7 +111,8 @@ ARGS_ANALYZE_ENTRIES_EXITS = ["exportfilename", "analysis_groups", "enter_reason NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", "list-timeframes", "list-markets", "list-pairs", "list-strategies", "list-freqaimodels", "list-data", "hyperopt-list", "hyperopt-show", "backtest-filter", - "plot-dataframe", "plot-profit", "show-trades", "trades-to-ohlcv"] + "plot-dataframe", "plot-profit", "show-trades", "trades-to-ohlcv", + "strategy-updater"] NO_CONF_ALLOWED = ["create-userdir", "list-exchanges", "new-strategy"] From 61d7129d7ce65edcbbdd75f7047d47ad75051cce Mon Sep 17 00:00:00 2001 From: hippocritical <41228167+hippocritical@users.noreply.github.com> Date: Mon, 2 Jan 2023 16:51:05 +0100 Subject: [PATCH 4/4] Update freqtrade/commands/strategy_utils_commands.py Co-authored-by: Matthias --- freqtrade/commands/strategy_utils_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/commands/strategy_utils_commands.py b/freqtrade/commands/strategy_utils_commands.py index 1f3c27e0d..0325f411c 100644 --- a/freqtrade/commands/strategy_utils_commands.py +++ b/freqtrade/commands/strategy_utils_commands.py @@ -39,4 +39,4 @@ def start_strategy_update(args: Dict[str, Any]) -> None: for filtered_strategy_obj in filtered_strategy_objs: # Initialize backtesting object instance_strategy_updater = StrategyUpdater() - StrategyUpdater.start(instance_strategy_updater, config, filtered_strategy_obj) + self.start(config, filtered_strategy_obj)