Remove usage of args.

It's clumsy to use and prevents specifying settings in the configuration.
This commit is contained in:
Matthias
2023-05-20 11:02:13 +02:00
parent 5488789bc4
commit 2e79aaae00
2 changed files with 10 additions and 14 deletions
+4 -7
View File
@@ -144,7 +144,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
""" """
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
if args['targeted_trade_amount'] < args['minimum_trade_amount']: if config['targeted_trade_amount'] < config['minimum_trade_amount']:
# add logic that tells the user to check the configuration # add logic that tells the user to check the configuration
# since this combo doesn't make any sense. # since this combo doesn't make any sense.
pass pass
@@ -153,13 +153,10 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False)) config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
lookaheadAnalysis_instances = [] lookaheadAnalysis_instances = []
strategy_list = []
# unify --strategy and --strategy_list to one list # unify --strategy and --strategy_list to one list
if 'strategy' in args and args['strategy'] is not None: if not (strategy_list := config.get('strategy_list', [])):
strategy_list = [args['strategy']] strategy_list = [config['strategy']]
else:
strategy_list = args['strategy_list']
# check if strategies can be properly loaded, only check them if they can be. # check if strategies can be properly loaded, only check them if they can be.
if strategy_list is not None: if strategy_list is not None:
@@ -168,7 +165,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
if strategy_obj['name'] == strat and strategy_obj not in strategy_list: if strategy_obj['name'] == strat and strategy_obj not in strategy_list:
lookaheadAnalysis_instances.append( lookaheadAnalysis_instances.append(
LookaheadAnalysisSubFunctions.initialize_single_lookahead_analysis( LookaheadAnalysisSubFunctions.initialize_single_lookahead_analysis(
strategy_obj, config, args)) strategy_obj, config))
break break
# report the results # report the results
+6 -7
View File
@@ -42,7 +42,7 @@ class Analysis:
class LookaheadAnalysis: class LookaheadAnalysis:
def __init__(self, config: Dict[str, Any], strategy_obj: dict, args: Dict[str, Any]): def __init__(self, config: Dict[str, Any], strategy_obj: Dict):
self.failed_bias_check = True self.failed_bias_check = True
self.full_varHolder = VarHolder self.full_varHolder = VarHolder
@@ -53,9 +53,9 @@ class LookaheadAnalysis:
self.local_config = deepcopy(config) self.local_config = deepcopy(config)
self.local_config['strategy'] = strategy_obj['name'] self.local_config['strategy'] = strategy_obj['name']
self.current_analysis = Analysis() self.current_analysis = Analysis()
self.minimum_trade_amount = args['minimum_trade_amount'] self.minimum_trade_amount = config['minimum_trade_amount']
self.targeted_trade_amount = args['targeted_trade_amount'] self.targeted_trade_amount = config['targeted_trade_amount']
self.exportfilename = args['exportfilename'] self.exportfilename = config['exportfilename']
self.strategy_obj = strategy_obj self.strategy_obj = strategy_obj
@staticmethod @staticmethod
@@ -339,12 +339,11 @@ class LookaheadAnalysisSubFunctions:
csv_df.to_csv(config['lookahead_analysis_exportfilename'], index=False) csv_df.to_csv(config['lookahead_analysis_exportfilename'], index=False)
@staticmethod @staticmethod
def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any], def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any]):
args: Dict[str, Any]):
logger.info(f"Bias test of {Path(strategy_obj['location']).name} started.") logger.info(f"Bias test of {Path(strategy_obj['location']).name} started.")
start = time.perf_counter() start = time.perf_counter()
current_instance = LookaheadAnalysis(config, strategy_obj, args) current_instance = LookaheadAnalysis(config, strategy_obj)
current_instance.start() current_instance.start()
elapsed = time.perf_counter() - start elapsed = time.perf_counter() - start
logger.info(f"checking look ahead bias via backtests " logger.info(f"checking look ahead bias via backtests "