2022-12-27 19:14:39 +00:00
|
|
|
import logging
|
2023-01-05 21:56:06 +00:00
|
|
|
import time
|
2022-12-27 19:14:39 +00:00
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
|
|
from freqtrade.configuration import setup_utils_configuration
|
|
|
|
from freqtrade.enums import RunMode
|
|
|
|
from freqtrade.resolvers import StrategyResolver
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def start_strategy_update(args: Dict[str, Any]) -> None:
|
|
|
|
"""
|
|
|
|
Start the strategy updating script
|
|
|
|
:param args: Cli args from Arguments()
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Import here to avoid loading backtesting module when it's not used
|
2022-12-29 21:17:52 +00:00
|
|
|
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
2022-12-27 19:14:39 +00:00
|
|
|
|
|
|
|
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
|
|
|
|
|
|
|
strategy_objs = StrategyResolver.search_all_objects(
|
2023-01-02 19:45:56 +00:00
|
|
|
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
|
2022-12-27 19:14:39 +00:00
|
|
|
|
|
|
|
filtered_strategy_objs = []
|
2023-01-01 11:37:15 +00:00
|
|
|
for args_strategy in args['strategy_list']:
|
|
|
|
for strategy_obj in strategy_objs:
|
2022-12-27 19:14:39 +00:00
|
|
|
if strategy_obj['name'] == args_strategy and strategy_obj not in filtered_strategy_objs:
|
|
|
|
filtered_strategy_objs.append(strategy_obj)
|
|
|
|
break
|
2023-01-01 11:37:15 +00:00
|
|
|
|
2022-12-27 19:14:39 +00:00
|
|
|
for filtered_strategy_obj in filtered_strategy_objs:
|
2022-12-29 21:17:52 +00:00
|
|
|
instance_strategy_updater = StrategyUpdater()
|
2023-01-05 21:56:06 +00:00
|
|
|
start = time.perf_counter()
|
2023-01-02 22:35:51 +00:00
|
|
|
instance_strategy_updater.start(config, filtered_strategy_obj)
|
2023-01-05 21:56:06 +00:00
|
|
|
elapsed = time.perf_counter() - start
|
|
|
|
print(f"Conversion of {filtered_strategy_obj['name']} took {elapsed:.1f} seconds.")
|