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

View File

@@ -144,7 +144,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
"""
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
# since this combo doesn't make any sense.
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))
lookaheadAnalysis_instances = []
strategy_list = []
# unify --strategy and --strategy_list to one list
if 'strategy' in args and args['strategy'] is not None:
strategy_list = [args['strategy']]
else:
strategy_list = args['strategy_list']
if not (strategy_list := config.get('strategy_list', [])):
strategy_list = [config['strategy']]
# check if strategies can be properly loaded, only check them if they can be.
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:
lookaheadAnalysis_instances.append(
LookaheadAnalysisSubFunctions.initialize_single_lookahead_analysis(
strategy_obj, config, args))
strategy_obj, config))
break
# report the results

View File

@@ -42,7 +42,7 @@ class Analysis:
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.full_varHolder = VarHolder
@@ -53,9 +53,9 @@ class LookaheadAnalysis:
self.local_config = deepcopy(config)
self.local_config['strategy'] = strategy_obj['name']
self.current_analysis = Analysis()
self.minimum_trade_amount = args['minimum_trade_amount']
self.targeted_trade_amount = args['targeted_trade_amount']
self.exportfilename = args['exportfilename']
self.minimum_trade_amount = config['minimum_trade_amount']
self.targeted_trade_amount = config['targeted_trade_amount']
self.exportfilename = config['exportfilename']
self.strategy_obj = strategy_obj
@staticmethod
@@ -339,12 +339,11 @@ class LookaheadAnalysisSubFunctions:
csv_df.to_csv(config['lookahead_analysis_exportfilename'], index=False)
@staticmethod
def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any],
args: Dict[str, Any]):
def initialize_single_lookahead_analysis(strategy_obj: Dict[str, Any], config: Dict[str, Any]):
logger.info(f"Bias test of {Path(strategy_obj['location']).name} started.")
start = time.perf_counter()
current_instance = LookaheadAnalysis(config, strategy_obj, args)
current_instance = LookaheadAnalysis(config, strategy_obj)
current_instance.start()
elapsed = time.perf_counter() - start
logger.info(f"checking look ahead bias via backtests "