From 8591b0f0cb20c2a4e10595ad7198a72b4fd0f2bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 25 May 2025 12:17:03 +0200 Subject: [PATCH] refactor(qav3): refine log messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 20 ++++++++++--------- .../user_data/strategies/QuickAdapterV3.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 6367f20..1e2dc85 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -473,10 +473,12 @@ class QuickAdapterRegressorV3(BaseRegressionModel): is_study_single_objective = direction is not None and directions is None if is_study_single_objective is True: - objective_type = "single objective" + objective_type = "single" else: - objective_type = "multi objective" - logger.info(f"Optuna {pair} {namespace} {objective_type} hyperopt started") + objective_type = "multi" + logger.info( + f"Optuna {pair} {namespace} {objective_type} objective hyperopt started" + ) start_time = time.time() try: study.optimize( @@ -489,7 +491,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): except Exception as e: time_spent = time.time() - start_time logger.error( - f"Optuna {pair} {namespace} {objective_type} hyperopt failed ({time_spent:.2f} secs): {str(e)}", + f"Optuna {pair} {namespace} {objective_type} objective hyperopt failed ({time_spent:.2f} secs): {str(e)}", exc_info=True, ) return @@ -498,7 +500,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): if is_study_single_objective: if not QuickAdapterRegressorV3.optuna_study_has_best_trial(study): logger.error( - f"Optuna {pair} {namespace} {objective_type} hyperopt failed ({time_spent:.2f} secs): no study best trial found" + f"Optuna {pair} {namespace} {objective_type} objective hyperopt failed ({time_spent:.2f} secs): no study best trial found" ) return self.set_optuna_value(pair, namespace, study.best_value) @@ -511,7 +513,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): best_trial = self.get_multi_objective_study_best_trial("label", study) if not best_trial: logger.error( - f"Optuna {pair} {namespace} {objective_type} hyperopt failed ({time_spent:.2f} secs): no study best trial found" + f"Optuna {pair} {namespace} {objective_type} objective hyperopt failed ({time_spent:.2f} secs): no study best trial found" ) return self.set_optuna_values(pair, namespace, best_trial.values) @@ -521,11 +523,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel): **self.get_optuna_params(pair, namespace), } logger.info( - f"Optuna {pair} {namespace} {objective_type} done ({time_spent:.2f} secs)" + f"Optuna {pair} {namespace} {objective_type} objective done ({time_spent:.2f} secs)" ) for key, value in study_results.items(): logger.info( - f"Optuna {pair} {namespace} {objective_type} hyperopt | {key:>20s} : {value}" + f"Optuna {pair} {namespace} {objective_type} objective hyperopt | {key:>20s} : {value}" ) self.optuna_save_best_params(pair, namespace) @@ -566,7 +568,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): storage = self.optuna_storage(pair) except Exception as e: logger.error( - f"Failed to create optuna storage for {study_name}: {str(e)}", + f"Failed to create optuna storage for study {study_name}: {str(e)}", exc_info=True, ) return None diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index ab31045..f4b0b39 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -390,7 +390,7 @@ class QuickAdapterV3(IStrategy): dataframe[EXTREMA_COLUMN] = 0 if len(pivots_indices) == 0: logger.warning( - f"No extrema to label for pair {pair} with label_period_candles {self.get_label_period_candles(pair)} and label_natr_ratio {self.get_label_natr_ratio(pair)}" + f"No extrema to label for pair {pair} with label_period_candles {self.get_label_period_candles(pair)} and label_natr_ratio {self.get_label_natr_ratio(pair):.2f}" ) else: for pivot_idx, pivot_dir in zip(pivots_indices, pivots_directions): -- 2.43.0