Merge remote-tracking branch 'origin/strategy_utils' into strategy_utils
This commit is contained in:
commit
697fad0ac4
@ -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"]
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
@ -186,9 +186,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)
|
||||
|
||||
@ -210,9 +212,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)
|
||||
|
||||
@ -255,8 +259,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
|
||||
|
Loading…
Reference in New Issue
Block a user