freqtrades' merge broke my side, fixed it by porting it over to my develop branch, no changes with this commit logic-wise.

This commit is contained in:
hippocritical
2023-03-22 12:32:39 +01:00
parent ce3efa8f00
commit d12a7ff18b
4 changed files with 308 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ from freqtrade.commands.optimize_commands import (start_backtesting, start_backt
start_edge, start_hyperopt)
from freqtrade.commands.pairlist_commands import start_test_pairlist
from freqtrade.commands.plot_commands import start_plot_dataframe, start_plot_profit
from freqtrade.commands.strategy_utils_commands import start_strategy_update
from freqtrade.commands.strategy_utils_commands import (start_backtest_lookahead_bias_checker,
start_strategy_update)
from freqtrade.commands.trade_commands import start_trading
from freqtrade.commands.webserver_commands import start_webserver

View File

@@ -116,8 +116,14 @@ NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", "list
NO_CONF_ALLOWED = ["create-userdir", "list-exchanges", "new-strategy"]
ARGS_STRATEGY_UTILS = ["strategy_list", "strategy_path", "recursive_strategy_search"]
ARGS_STRATEGY_UPDATER = ARGS_COMMON_OPTIMIZE + ["strategy_list"]
ARGS_BACKTEST_LOOKAHEAD_BIAS_CHECKER = ARGS_BACKTEST
# + ["target_trades", "minimum_trades",
# "target_trades", "exportfilename"]
# will be added when the base version works.
class Arguments:
"""
@@ -192,7 +198,8 @@ class Arguments:
self.parser = argparse.ArgumentParser(description='Free, open source crypto trading bot')
self._build_args(optionlist=['version'], parser=self.parser)
from freqtrade.commands import (start_analysis_entries_exits, start_backtesting,
from freqtrade.commands import (start_analysis_entries_exits,
start_backtest_lookahead_bias_checker, start_backtesting,
start_backtesting_show, start_convert_data,
start_convert_db, start_convert_trades,
start_create_userdir, start_download_data, start_edge,
@@ -450,4 +457,14 @@ class Arguments:
'files to the current version',
parents=[_common_parser])
strategy_updater_cmd.set_defaults(func=start_strategy_update)
self._build_args(optionlist=ARGS_STRATEGY_UTILS, parser=strategy_updater_cmd)
self._build_args(optionlist=ARGS_STRATEGY_UPDATER, parser=strategy_updater_cmd)
# Add backtest lookahead bias checker subcommand
backtest_lookahead_bias_checker_cmd = \
subparsers.add_parser('backtest_lookahead_bias_checker',
help="checks for potential look ahead bias",
parents=[_common_parser])
backtest_lookahead_bias_checker_cmd.set_defaults(func=start_backtest_lookahead_bias_checker)
self._build_args(optionlist=ARGS_BACKTEST_LOOKAHEAD_BIAS_CHECKER,
parser=backtest_lookahead_bias_checker_cmd)

View File

@@ -7,6 +7,7 @@ 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.backtest_lookahead_bias_checker import backtest_lookahead_bias_checker
from freqtrade.strategy.strategyupdater import StrategyUpdater
@@ -53,3 +54,47 @@ def start_conversion(strategy_obj, config):
instance_strategy_updater.start(config, strategy_obj)
elapsed = time.perf_counter() - start
print(f"Conversion of {Path(strategy_obj['location']).name} took {elapsed:.1f} seconds.")
# except:
# pass
def start_backtest_lookahead_bias_checker(args: Dict[str, Any]) -> None:
"""
Start the backtest bias tester script
:param args: Cli args from Arguments()
:return: None
"""
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 = []
if 'strategy_list' in args and args['strategy_list'] is not None:
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:
initialize_single_lookahead_bias_checker(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'])
initialize_single_lookahead_bias_checker(strategy_obj, config)
def initialize_single_lookahead_bias_checker(strategy_obj, config):
# try:
print(f"Bias test of {Path(strategy_obj['location']).name} started.")
instance_backtest_lookahead_bias_checker = backtest_lookahead_bias_checker()
start = time.perf_counter()
instance_backtest_lookahead_bias_checker.start(config, strategy_obj)
elapsed = time.perf_counter() - start
print(f"checking look ahead bias via backtests of {Path(strategy_obj['location']).name} "
f"took {elapsed:.1f} seconds.")