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:
@@ -121,7 +121,7 @@ ARGS_STRATEGY_UPDATER = ["strategy_list", "strategy_path", "recursive_strategy_s
|
|||||||
|
|
||||||
ARGS_LOOKAHEAD_ANALYSIS = ARGS_BACKTEST + ["minimum_trade_amount",
|
ARGS_LOOKAHEAD_ANALYSIS = ARGS_BACKTEST + ["minimum_trade_amount",
|
||||||
"targeted_trade_amount",
|
"targeted_trade_amount",
|
||||||
"overwrite_existing_exportfilename_content"]
|
"lookahead_analysis_exportfilename"]
|
||||||
|
|
||||||
|
|
||||||
# + ["target_trades", "minimum_trades",
|
# + ["target_trades", "minimum_trades",
|
||||||
|
|||||||
@@ -704,9 +704,10 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
metavar='INT',
|
metavar='INT',
|
||||||
default=20,
|
default=20,
|
||||||
),
|
),
|
||||||
"overwrite_existing_exportfilename_content": Arg(
|
"lookahead_analysis_exportfilename": Arg(
|
||||||
'--overwrite-existing-exportfilename-content',
|
'--lookahead-analysis-exportfilename',
|
||||||
help='overwrites existing contents if existent with exportfilename given',
|
help="Use this filename to store lookahead-analysis-results",
|
||||||
action='store_true'
|
default=None,
|
||||||
)
|
type=str
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
|
|||||||
if lookaheadAnalysis_instances:
|
if lookaheadAnalysis_instances:
|
||||||
LookaheadAnalysisSubFunctions.text_table_lookahead_analysis_instances(
|
LookaheadAnalysisSubFunctions.text_table_lookahead_analysis_instances(
|
||||||
lookaheadAnalysis_instances)
|
lookaheadAnalysis_instances)
|
||||||
if args['exportfilename'] is not None:
|
if config['lookahead_analysis_exportfilename'] is not None:
|
||||||
LookaheadAnalysisSubFunctions.export_to_csv(args, lookaheadAnalysis_instances)
|
LookaheadAnalysisSubFunctions.export_to_csv(config, lookaheadAnalysis_instances)
|
||||||
else:
|
else:
|
||||||
logger.error("There were no strategies specified neither through "
|
logger.error("There were no strategies specified neither through "
|
||||||
"--strategy nor through "
|
"--strategy nor through "
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ class Configuration:
|
|||||||
# This will override the strategy configuration
|
# This will override the strategy configuration
|
||||||
self._args_to_config(config, argname='timeframe',
|
self._args_to_config(config, argname='timeframe',
|
||||||
logstring='Parameter -i/--timeframe detected ... '
|
logstring='Parameter -i/--timeframe detected ... '
|
||||||
'Using timeframe: {} ...')
|
'Using timeframe: {} ...')
|
||||||
|
|
||||||
self._args_to_config(config, argname='position_stacking',
|
self._args_to_config(config, argname='position_stacking',
|
||||||
logstring='Parameter --enable-position-stacking detected ...')
|
logstring='Parameter --enable-position-stacking detected ...')
|
||||||
@@ -300,6 +300,10 @@ class Configuration:
|
|||||||
self._args_to_config(config, argname='hyperoptexportfilename',
|
self._args_to_config(config, argname='hyperoptexportfilename',
|
||||||
logstring='Using hyperopt file: {}')
|
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',
|
self._args_to_config(config, argname='epochs',
|
||||||
logstring='Parameter --epochs detected ... '
|
logstring='Parameter --epochs detected ... '
|
||||||
'Will run Hyperopt with for {} epochs ...'
|
'Will run Hyperopt with for {} epochs ...'
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ class LookaheadAnalysisSubFunctions:
|
|||||||
print(table)
|
print(table)
|
||||||
|
|
||||||
@staticmethod
|
@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):
|
def add_or_update_row(df, row_data):
|
||||||
if (
|
if (
|
||||||
(df['filename'] == row_data['filename']) &
|
(df['filename'] == row_data['filename']) &
|
||||||
@@ -314,9 +314,9 @@ class LookaheadAnalysisSubFunctions:
|
|||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
if Path(args['exportfilename']).exists():
|
if Path(config['lookahead_analysis_exportfilename']).exists():
|
||||||
# Read CSV file into a pandas dataframe
|
# Read CSV file into a pandas dataframe
|
||||||
csv_df = pd.read_csv(args['exportfilename'])
|
csv_df = pd.read_csv(config['lookahead_analysis_exportfilename'])
|
||||||
else:
|
else:
|
||||||
# Create a new empty DataFrame with the desired column names and set the index
|
# Create a new empty DataFrame with the desired column names and set the index
|
||||||
csv_df = pd.DataFrame(columns=[
|
csv_df = pd.DataFrame(columns=[
|
||||||
@@ -335,8 +335,8 @@ class LookaheadAnalysisSubFunctions:
|
|||||||
'biased_indicators': ",".join(inst.current_analysis.false_indicators)}
|
'biased_indicators': ",".join(inst.current_analysis.false_indicators)}
|
||||||
csv_df = add_or_update_row(csv_df, new_row_data)
|
csv_df = add_or_update_row(csv_df, new_row_data)
|
||||||
|
|
||||||
logger.info(f"saving {args['exportfilename']}")
|
logger.info(f"saving {config['lookahead_analysis_exportfilename']}")
|
||||||
csv_df.to_csv(args['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],
|
||||||
|
|||||||
Reference in New Issue
Block a user