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
This commit is contained in:
hippocritical 2023-05-10 22:41:27 +02:00
parent 9aac367534
commit 91ce1cb2ae
5 changed files with 19 additions and 14 deletions

View File

@ -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",

View File

@ -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
),
}

View File

@ -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 "

View File

@ -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 ...'

View File

@ -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],