From 91ce1cb2aeab0ff332bb2a0b3a6823c426c571cf Mon Sep 17 00:00:00 2001 From: hippocritical Date: Wed, 10 May 2023 22:41:27 +0200 Subject: [PATCH] removed overwrite_existing_exportfilename_content (won't use it myself, wouldn't make sense for others to not overwrite something they re-calculated) switched from args to config (args still work) renamed exportfilename to lookahead_analysis_exportfilename so if users decide to put something into it then it won't compete with other configurations --- freqtrade/commands/arguments.py | 2 +- freqtrade/commands/cli_options.py | 11 ++++++----- freqtrade/commands/optimize_commands.py | 4 ++-- freqtrade/configuration/configuration.py | 6 +++++- freqtrade/optimize/lookahead_analysis.py | 10 +++++----- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index f0419a7d9..af5f0a470 100755 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -121,7 +121,7 @@ ARGS_STRATEGY_UPDATER = ["strategy_list", "strategy_path", "recursive_strategy_s ARGS_LOOKAHEAD_ANALYSIS = ARGS_BACKTEST + ["minimum_trade_amount", "targeted_trade_amount", - "overwrite_existing_exportfilename_content"] + "lookahead_analysis_exportfilename"] # + ["target_trades", "minimum_trades", diff --git a/freqtrade/commands/cli_options.py b/freqtrade/commands/cli_options.py index 77f8f2005..5dd587559 100755 --- a/freqtrade/commands/cli_options.py +++ b/freqtrade/commands/cli_options.py @@ -704,9 +704,10 @@ AVAILABLE_CLI_OPTIONS = { metavar='INT', default=20, ), - "overwrite_existing_exportfilename_content": Arg( - '--overwrite-existing-exportfilename-content', - help='overwrites existing contents if existent with exportfilename given', - action='store_true' - ) + "lookahead_analysis_exportfilename": Arg( + '--lookahead-analysis-exportfilename', + help="Use this filename to store lookahead-analysis-results", + default=None, + type=str + ), } diff --git a/freqtrade/commands/optimize_commands.py b/freqtrade/commands/optimize_commands.py index 765f2caf2..78ad140de 100644 --- a/freqtrade/commands/optimize_commands.py +++ b/freqtrade/commands/optimize_commands.py @@ -175,8 +175,8 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None: if lookaheadAnalysis_instances: LookaheadAnalysisSubFunctions.text_table_lookahead_analysis_instances( lookaheadAnalysis_instances) - if args['exportfilename'] is not None: - LookaheadAnalysisSubFunctions.export_to_csv(args, lookaheadAnalysis_instances) + if config['lookahead_analysis_exportfilename'] is not None: + LookaheadAnalysisSubFunctions.export_to_csv(config, lookaheadAnalysis_instances) else: logger.error("There were no strategies specified neither through " "--strategy nor through " diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 8e9a7fd7c..defb76b4b 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -203,7 +203,7 @@ class Configuration: # This will override the strategy configuration self._args_to_config(config, argname='timeframe', logstring='Parameter -i/--timeframe detected ... ' - 'Using timeframe: {} ...') + 'Using timeframe: {} ...') self._args_to_config(config, argname='position_stacking', logstring='Parameter --enable-position-stacking detected ...') @@ -300,6 +300,10 @@ class Configuration: self._args_to_config(config, argname='hyperoptexportfilename', logstring='Using hyperopt file: {}') + if self.args["lookahead_analysis_exportfilename"] is not None: + self._args_to_config(config, argname='lookahead_analysis_exportfilename', + logstring='saving lookahead analysis results into {} ...') + self._args_to_config(config, argname='epochs', logstring='Parameter --epochs detected ... ' 'Will run Hyperopt with for {} epochs ...' diff --git a/freqtrade/optimize/lookahead_analysis.py b/freqtrade/optimize/lookahead_analysis.py index 3ca1b71a0..8e6771b4b 100755 --- a/freqtrade/optimize/lookahead_analysis.py +++ b/freqtrade/optimize/lookahead_analysis.py @@ -296,7 +296,7 @@ class LookaheadAnalysisSubFunctions: print(table) @staticmethod - def export_to_csv(args: Dict[str, Any], lookahead_analysis: List[LookaheadAnalysis]): + def export_to_csv(config: Dict[str, Any], lookahead_analysis: List[LookaheadAnalysis]): def add_or_update_row(df, row_data): if ( (df['filename'] == row_data['filename']) & @@ -314,9 +314,9 @@ class LookaheadAnalysisSubFunctions: return df - if Path(args['exportfilename']).exists(): + if Path(config['lookahead_analysis_exportfilename']).exists(): # Read CSV file into a pandas dataframe - csv_df = pd.read_csv(args['exportfilename']) + csv_df = pd.read_csv(config['lookahead_analysis_exportfilename']) else: # Create a new empty DataFrame with the desired column names and set the index csv_df = pd.DataFrame(columns=[ @@ -335,8 +335,8 @@ class LookaheadAnalysisSubFunctions: 'biased_indicators': ",".join(inst.current_analysis.false_indicators)} csv_df = add_or_update_row(csv_df, new_row_data) - logger.info(f"saving {args['exportfilename']}") - csv_df.to_csv(args['exportfilename'], index=False) + logger.info(f"saving {config['lookahead_analysis_exportfilename']}") + 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],