strategy_updater:
removed args_common_optimize for strategy-updater backtest_lookahead_bias_checker: added args and cli-options for minimum and target trade amounts fixed code according to best-practice coding requests of matthias (CamelCase etc)
This commit is contained in:
@@ -116,9 +116,10 @@ NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", "list
|
||||
|
||||
NO_CONF_ALLOWED = ["create-userdir", "list-exchanges", "new-strategy"]
|
||||
|
||||
ARGS_STRATEGY_UPDATER = ARGS_COMMON_OPTIMIZE + ["strategy_list"]
|
||||
ARGS_STRATEGY_UPDATER = ["strategy_list"]
|
||||
|
||||
ARGS_BACKTEST_LOOKAHEAD_BIAS_CHECKER = ARGS_BACKTEST
|
||||
ARGS_BACKTEST_LOOKAHEAD_BIAS_CHECKER = ARGS_BACKTEST + ["minimum_trade_amount",
|
||||
"targeted_trade_amount"]
|
||||
|
||||
|
||||
# + ["target_trades", "minimum_trades",
|
||||
@@ -461,7 +462,7 @@ class Arguments:
|
||||
|
||||
# Add backtest lookahead bias checker subcommand
|
||||
backtest_lookahead_bias_checker_cmd = \
|
||||
subparsers.add_parser('backtest_lookahead_bias_checker',
|
||||
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)
|
||||
|
@@ -675,4 +675,18 @@ AVAILABLE_CLI_OPTIONS = {
|
||||
help='Run backtest with ready models.',
|
||||
action='store_true'
|
||||
),
|
||||
"minimum_trade_amount": Arg(
|
||||
'--minimum-trade-amount',
|
||||
help='set INT minimum trade amount',
|
||||
type=check_int_positive,
|
||||
metavar='INT',
|
||||
default=10,
|
||||
),
|
||||
"targeted_trade_amount": Arg(
|
||||
'--targeted-trade-amount',
|
||||
help='set INT targeted trade amount',
|
||||
type=check_int_positive,
|
||||
metavar='INT',
|
||||
default=20,
|
||||
)
|
||||
}
|
||||
|
@@ -7,7 +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.backtest_lookahead_bias_checker import BacktestLookaheadBiasChecker
|
||||
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
||||
|
||||
|
||||
@@ -67,9 +67,16 @@ def start_backtest_lookahead_bias_checker(args: Dict[str, Any]) -> None:
|
||||
"""
|
||||
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
||||
|
||||
if args['targeted_trade_amount'] < args['minimum_trade_amount']:
|
||||
# add logic that tells the user to check the configuration
|
||||
# since this combo doesn't make any sense.
|
||||
pass
|
||||
|
||||
strategy_objs = StrategyResolver.search_all_objects(
|
||||
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
|
||||
|
||||
bias_checker_instances = []
|
||||
|
||||
filtered_strategy_objs = []
|
||||
if 'strategy_list' in args and args['strategy_list'] is not None:
|
||||
for args_strategy in args['strategy_list']:
|
||||
@@ -80,21 +87,29 @@ def start_backtest_lookahead_bias_checker(args: Dict[str, Any]) -> None:
|
||||
break
|
||||
|
||||
for filtered_strategy_obj in filtered_strategy_objs:
|
||||
initialize_single_lookahead_bias_checker(filtered_strategy_obj, config)
|
||||
bias_checker_instances = initialize_single_lookahead_bias_checker(
|
||||
filtered_strategy_obj, config, args)
|
||||
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)
|
||||
bias_checker_instances = initialize_single_lookahead_bias_checker(
|
||||
strategy_obj, config, args)
|
||||
create_result_list(bias_checker_instances)
|
||||
|
||||
|
||||
def initialize_single_lookahead_bias_checker(strategy_obj, config):
|
||||
def create_result_list(bias_checker_instances):
|
||||
pass
|
||||
|
||||
|
||||
def initialize_single_lookahead_bias_checker(strategy_obj, config, args):
|
||||
# try:
|
||||
print(f"Bias test of {Path(strategy_obj['location']).name} started.")
|
||||
instance_backtest_lookahead_bias_checker = backtest_lookahead_bias_checker()
|
||||
instance_backtest_lookahead_bias_checker = BacktestLookaheadBiasChecker()
|
||||
start = time.perf_counter()
|
||||
instance_backtest_lookahead_bias_checker.start(config, strategy_obj)
|
||||
current_instance = instance_backtest_lookahead_bias_checker.start(config, strategy_obj, args)
|
||||
elapsed = time.perf_counter() - start
|
||||
print(f"checking look ahead bias via backtests of {Path(strategy_obj['location']).name} "
|
||||
f"took {elapsed:.1f} seconds.")
|
||||
return current_instance
|
||||
|
Reference in New Issue
Block a user