removed prints for strategy could not be loaded
Changed logic to contain much less if conditions currently still missing: Webhook terminology, Telegram notification settings, Strategy/Config settings
This commit is contained in:
parent
ed55296d20
commit
4435c4fd0d
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from freqtrade.configuration import setup_utils_configuration
|
from freqtrade.configuration import setup_utils_configuration
|
||||||
@ -33,4 +34,7 @@ def start_strategy_update(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
for filtered_strategy_obj in filtered_strategy_objs:
|
for filtered_strategy_obj in filtered_strategy_objs:
|
||||||
instance_strategy_updater = StrategyUpdater()
|
instance_strategy_updater = StrategyUpdater()
|
||||||
|
start = time.perf_counter()
|
||||||
instance_strategy_updater.start(config, filtered_strategy_obj)
|
instance_strategy_updater.start(config, filtered_strategy_obj)
|
||||||
|
elapsed = time.perf_counter() - start
|
||||||
|
print(f"Conversion of {filtered_strategy_obj['name']} took {elapsed:.1f} seconds.")
|
||||||
|
@ -52,7 +52,6 @@ class StrategyUpdater:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
source_file = strategy_obj['location']
|
source_file = strategy_obj['location']
|
||||||
print(f"started conversion of {source_file}")
|
|
||||||
strategies_backup_folder = Path.joinpath(config['user_data_dir'], "strategies_orig_updater")
|
strategies_backup_folder = Path.joinpath(config['user_data_dir'], "strategies_orig_updater")
|
||||||
target_file = Path.joinpath(strategies_backup_folder, strategy_obj['location_rel'])
|
target_file = Path.joinpath(strategies_backup_folder, strategy_obj['location_rel'])
|
||||||
|
|
||||||
@ -73,7 +72,6 @@ class StrategyUpdater:
|
|||||||
# write the modified code to the destination folder
|
# write the modified code to the destination folder
|
||||||
with open(source_file, 'w') as f:
|
with open(source_file, 'w') as f:
|
||||||
f.write(new_code)
|
f.write(new_code)
|
||||||
print(f"conversion of file {source_file} successful.")
|
|
||||||
|
|
||||||
# define the function to update the code
|
# define the function to update the code
|
||||||
def update_code(self, code):
|
def update_code(self, code):
|
||||||
@ -81,7 +79,7 @@ class StrategyUpdater:
|
|||||||
tree = ast.parse(code)
|
tree = ast.parse(code)
|
||||||
|
|
||||||
# use the AST to update the 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 the modified code without executing it
|
||||||
return updated_code
|
return updated_code
|
||||||
@ -96,6 +94,7 @@ class StrategyUpdater:
|
|||||||
ast.increment_lineno(tree, n=1)
|
ast.increment_lineno(tree, n=1)
|
||||||
|
|
||||||
# generate the new code from the updated AST
|
# generate the new code from the updated AST
|
||||||
|
# without indent {} parameters would just be written straight one after the other.
|
||||||
return astor.to_source(tree)
|
return astor.to_source(tree)
|
||||||
|
|
||||||
|
|
||||||
@ -131,8 +130,9 @@ class NameUpdater(ast.NodeTransformer):
|
|||||||
return node
|
return node
|
||||||
|
|
||||||
def visit_Expr(self, node):
|
def visit_Expr(self, node):
|
||||||
node.value.left.id = self.check_dict(StrategyUpdater.name_mapping, node.value.left.id)
|
if hasattr(node.value, "left") and hasattr(node.value.left, "id"):
|
||||||
self.visit(node.value)
|
node.value.left.id = self.check_dict(StrategyUpdater.name_mapping, node.value.left.id)
|
||||||
|
self.visit(node.value)
|
||||||
return node
|
return node
|
||||||
|
|
||||||
# Renames an element if contained inside a dictionary.
|
# Renames an element if contained inside a dictionary.
|
||||||
|
@ -4,7 +4,8 @@ from freqtrade.strategy.strategyupdater import StrategyUpdater
|
|||||||
|
|
||||||
|
|
||||||
def test_strategy_updater(default_conf, caplog) -> None:
|
def test_strategy_updater(default_conf, caplog) -> None:
|
||||||
modified_code1 = StrategyUpdater.update_code(StrategyUpdater, """
|
instance_strategy_updater = StrategyUpdater()
|
||||||
|
modified_code1 = instance_strategy_updater.update_code("""
|
||||||
class testClass(IStrategy):
|
class testClass(IStrategy):
|
||||||
def populate_buy_trend():
|
def populate_buy_trend():
|
||||||
pass
|
pass
|
||||||
@ -17,27 +18,27 @@ class testClass(IStrategy):
|
|||||||
def custom_sell():
|
def custom_sell():
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
modified_code2 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code2 = instance_strategy_updater.update_code("""
|
||||||
ticker_interval = '15m'
|
ticker_interval = '15m'
|
||||||
buy_some_parameter = IntParameter(space='buy')
|
buy_some_parameter = IntParameter(space='buy')
|
||||||
sell_some_parameter = IntParameter(space='sell')
|
sell_some_parameter = IntParameter(space='sell')
|
||||||
""")
|
""")
|
||||||
modified_code3 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code3 = instance_strategy_updater.update_code("""
|
||||||
use_sell_signal = True
|
use_sell_signal = True
|
||||||
sell_profit_only = True
|
sell_profit_only = True
|
||||||
sell_profit_offset = True
|
sell_profit_offset = True
|
||||||
ignore_roi_if_buy_signal = True
|
ignore_roi_if_buy_signal = True
|
||||||
forcebuy_enable = True
|
forcebuy_enable = True
|
||||||
""")
|
""")
|
||||||
modified_code4 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code4 = instance_strategy_updater.update_code("""
|
||||||
dataframe.loc[reduce(lambda x, y: x & y, conditions), ["buy", "buy_tag"]] = (1, "buy_signal_1")
|
dataframe.loc[reduce(lambda x, y: x & y, conditions), ["buy", "buy_tag"]] = (1, "buy_signal_1")
|
||||||
dataframe.loc[reduce(lambda x, y: x & y, conditions), 'sell'] = 1
|
dataframe.loc[reduce(lambda x, y: x & y, conditions), 'sell'] = 1
|
||||||
""")
|
""")
|
||||||
modified_code5 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code5 = instance_strategy_updater.update_code("""
|
||||||
def confirm_trade_exit(sell_reason: str):
|
def confirm_trade_exit(sell_reason: str):
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
modified_code6 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code6 = instance_strategy_updater.update_code("""
|
||||||
order_time_in_force = {
|
order_time_in_force = {
|
||||||
'buy': 'gtc',
|
'buy': 'gtc',
|
||||||
'sell': 'ioc'
|
'sell': 'ioc'
|
||||||
@ -54,12 +55,12 @@ unfilledtimeout = {
|
|||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
modified_code7 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code7 = instance_strategy_updater.update_code("""
|
||||||
def confirm_trade_exit(sell_reason):
|
def confirm_trade_exit(sell_reason):
|
||||||
if (sell_reason == 'stop_loss'):
|
if (sell_reason == 'stop_loss'):
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
modified_code8 = StrategyUpdater.update_code(StrategyUpdater, """
|
modified_code8 = instance_strategy_updater.update_code("""
|
||||||
sell_reason == 'sell_signal'
|
sell_reason == 'sell_signal'
|
||||||
sell_reason == 'force_sell'
|
sell_reason == 'force_sell'
|
||||||
sell_reason == 'emergency_sell'
|
sell_reason == 'emergency_sell'
|
||||||
|
Loading…
Reference in New Issue
Block a user