changed to ast_comments, added tests for comments.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from typing import Any, Dict
|
||||
|
||||
from freqtrade.configuration import setup_utils_configuration
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.resolvers import StrategyResolver
|
||||
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -17,24 +19,37 @@ def start_strategy_update(args: Dict[str, Any]) -> None:
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# Import here to avoid loading backtesting module when it's not used
|
||||
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
||||
|
||||
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
||||
|
||||
strategy_objs = StrategyResolver.search_all_objects(
|
||||
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
|
||||
|
||||
filtered_strategy_objs = []
|
||||
for args_strategy in args['strategy_list']:
|
||||
for strategy_obj in strategy_objs:
|
||||
if strategy_obj['name'] == args_strategy and strategy_obj not in filtered_strategy_objs:
|
||||
filtered_strategy_objs.append(strategy_obj)
|
||||
break
|
||||
if hasattr(args, "strategy_list"):
|
||||
for args_strategy in args['strategy_list']:
|
||||
for strategy_obj in strategy_objs:
|
||||
if (strategy_obj['name'] == args_strategy
|
||||
and strategy_obj not in filtered_strategy_objs):
|
||||
filtered_strategy_objs.append(strategy_obj)
|
||||
break
|
||||
|
||||
for filtered_strategy_obj in filtered_strategy_objs:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
start = time.perf_counter()
|
||||
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.")
|
||||
for filtered_strategy_obj in filtered_strategy_objs:
|
||||
start_conversion(filtered_strategy_obj, config)
|
||||
else:
|
||||
processed_locations = set()
|
||||
for strategy_obj in strategy_objs:
|
||||
if strategy_obj['location'] not in processed_locations:
|
||||
processed_locations.add(strategy_obj['location'])
|
||||
start_conversion(strategy_obj, config)
|
||||
|
||||
|
||||
def start_conversion(strategy_obj, config):
|
||||
# try:
|
||||
print(f"Conversion of {os.path.basename(strategy_obj['location'])} started.")
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
start = time.perf_counter()
|
||||
instance_strategy_updater.start(config, strategy_obj)
|
||||
elapsed = time.perf_counter() - start
|
||||
print(f"Conversion of {os.path.basename(strategy_obj['location'])} took {elapsed:.1f} seconds.")
|
||||
# except:
|
||||
# pass
|
||||
|
Reference in New Issue
Block a user