From 0817e1698f654a13fd6f01c2519dee5f1cc19f99 Mon Sep 17 00:00:00 2001 From: hippocritical Date: Mon, 2 Jan 2023 20:45:56 +0100 Subject: [PATCH] requirements thinned out again StrategyResolver.search_all_objects(enum_failed) set to False since we got no use in True shortened update_code call added modified_code8 test which currently still fails. (and thereby is commented out) --- freqtrade/commands/strategy_utils_commands.py | 2 +- freqtrade/strategy/strategyupdater.py | 8 +++++--- requirements.txt | 18 ------------------ tests/test_strategy_updater.py | 11 +++++++++++ 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/freqtrade/commands/strategy_utils_commands.py b/freqtrade/commands/strategy_utils_commands.py index 1f3c27e0d..5d8ede9a2 100644 --- a/freqtrade/commands/strategy_utils_commands.py +++ b/freqtrade/commands/strategy_utils_commands.py @@ -22,7 +22,7 @@ def start_strategy_update(args: Dict[str, Any]) -> None: config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) strategy_objs = StrategyResolver.search_all_objects( - config, enum_failed=True, recursive=config.get('recursive_strategy_search', False)) + config, enum_failed=False, recursive=config.get('recursive_strategy_search', False)) filtered_strategy_objs = [] for args_strategy in args['strategy_list']: diff --git a/freqtrade/strategy/strategyupdater.py b/freqtrade/strategy/strategyupdater.py index 1a0423076..7f3a1feff 100644 --- a/freqtrade/strategy/strategyupdater.py +++ b/freqtrade/strategy/strategyupdater.py @@ -69,7 +69,7 @@ class StrategyUpdater: shutil.copy(source_file, target_file) # update the code - new_code = StrategyUpdater.update_code(self, old_code) + new_code = self.update_code(old_code) # write the modified code to the destination folder with open(source_file, 'w') as f: f.write(new_code) @@ -113,7 +113,8 @@ class NameUpdater(ast.NodeTransformer): def check_fields(self, field_value): if isinstance(field_value, list): for item in field_value: - if isinstance(item, ast.AST) or isinstance(item, ast.If): + if (isinstance(item, ast.AST) or isinstance(item, ast.If) or + isinstance(item, ast.Expr)): self.visit(item) if isinstance(field_value, ast.Name): self.visit_Name(field_value) @@ -138,7 +139,8 @@ class NameUpdater(ast.NodeTransformer): if hasattr(node, "args"): if isinstance(node.args, list): for arg in node.args: - arg.arg = StrategyUpdater.name_mapping[arg.arg] + if arg.arg in StrategyUpdater.name_mapping: + arg.arg = StrategyUpdater.name_mapping[arg.arg] return node def visit_Name(self, node): diff --git a/requirements.txt b/requirements.txt index 3229ec3c4..da1db316b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -58,22 +58,4 @@ schedule==1.1.0 websockets==10.4 janus==1.0.0 -pytest~=7.2.0 -freqtrade~=2022.12.dev0 -filelock~=3.8.2 -plotly~=5.11.0 -setuptools~=65.6.3 -starlette~=0.22.0 -gym~=0.21.0 -torch~=1.13.1 -scikit-learn~=1.1.3 -scipy~=1.9.3 -xgboost~=1.7.2 -catboost~=1.1.1 -lightgbm~=3.3.3 astor~=0.8.1 -ta~=0.10.2 -finta~=1.3 -tapy~=1.9.1 -matplotlib~=3.6.2 -PyYAML~=6.0 diff --git a/tests/test_strategy_updater.py b/tests/test_strategy_updater.py index 5736e5c76..682c715fe 100644 --- a/tests/test_strategy_updater.py +++ b/tests/test_strategy_updater.py @@ -59,6 +59,11 @@ def confirm_trade_exit(sell_reason): if (sell_reason == 'stop_loss'): pass """) + # modified_code8 = StrategyUpdater.update_code(StrategyUpdater, """ + # sell_reason == 'sell_signal' + # sell_reason == 'force_sell' + # sell_reason == 'emergency_sell' + # """) assert "populate_entry_trend" in modified_code1 assert "populate_exit_trend" in modified_code1 @@ -93,3 +98,9 @@ def confirm_trade_exit(sell_reason): assert "exit_reason" in modified_code7 assert "exit_reason == 'stop_loss'" in modified_code7 + + # those tests currently don't work, next in line. + # assert "exit_signal" in modified_code8 + # assert "exit_reason" in modified_code8 + # assert "force_exit" in modified_code8 + # assert "emergency_exit" in modified_code8