From db4e7ada8c72c60a8e133ab5d9129b90bc199f65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 8 Aug 2025 13:28:15 +0200 Subject: [PATCH] fix(qav3): missing import MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ReforceXY/user_data/freqaimodels/ReforceXY.py | 6 +++--- .../freqaimodels/QuickAdapterRegressorV3.py | 15 +++++++++------ .../user_data/strategies/QuickAdapterV3.py | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ReforceXY/user_data/freqaimodels/ReforceXY.py b/ReforceXY/user_data/freqaimodels/ReforceXY.py index de8a6df..03d5560 100644 --- a/ReforceXY/user_data/freqaimodels/ReforceXY.py +++ b/ReforceXY/user_data/freqaimodels/ReforceXY.py @@ -401,7 +401,7 @@ class ReforceXY(BaseReinforcementLearningModel): ) return best_model except Exception as e: - logger.error(f"Error loading best model: {e}", exc_info=True) + logger.error(f"Error loading best model: {repr(e)}", exc_info=True) logger.info("Couldn't find best model, using final model instead.") @@ -568,7 +568,7 @@ class ReforceXY(BaseReinforcementLearningModel): except Exception as e: time_spent = time.time() - start_time logger.error( - f"Hyperopt {study_name} failed ({time_spent:.2f} secs): {e}", + f"Hyperopt {study_name} failed ({time_spent:.2f} secs): {repr(e)}", exc_info=True, ) hyperopt_failed = True @@ -634,7 +634,7 @@ class ReforceXY(BaseReinforcementLearningModel): json.dump(best_trial_params, write_file, indent=4) except Exception as e: logger.error( - f"Error saving best trial params to {best_trial_params_path}: {e}", + f"Error saving best trial params to {best_trial_params_path}: {repr(e)}", exc_info=True, ) raise diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index fba0e28..87feb22 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -26,6 +26,7 @@ from Utils import ( get_optuna_study_model_parameters, largest_divisor, round_to_nearest_int, + soft_extremum, zigzag, ) @@ -394,7 +395,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): callback() except Exception as e: logger.error( - f"Error executing optuna {pair} {namespace} callback: {str(e)}", + f"Error executing optuna {pair} {namespace} callback: {repr(e)}", exc_info=True, ) finally: @@ -644,7 +645,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): return threshold_func(values) except Exception as e: logger.warning( - f"Failed to apply skimage threshold function {threshold_func.__name__} on series {series.name}: {str(e)}. Falling back to median", + f"Failed to apply skimage threshold function {threshold_func.__name__} on series {series.name}: {repr(e)}. Falling back to median", exc_info=True, ) return np.median(values) @@ -971,7 +972,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): except Exception as e: time_spent = time.time() - start_time logger.error( - f"Optuna {pair} {namespace} {objective_type} objective hyperopt failed ({time_spent:.2f} secs): {str(e)}", + f"Optuna {pair} {namespace} {objective_type} objective hyperopt failed ({time_spent:.2f} secs): {repr(e)}", exc_info=True, ) return @@ -1016,6 +1017,8 @@ class QuickAdapterRegressorV3(BaseRegressionModel): ) elif isinstance(value, (int, float)): formatted_value = format_number(value) + else: + formatted_value = repr(value) logger.info( f"Optuna {pair} {namespace} {objective_type} objective hyperopt | {key:>20s} : {formatted_value}" ) @@ -1063,7 +1066,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): storage = self.optuna_storage(pair) except Exception as e: logger.error( - f"Failed to create optuna storage for study {study_name}: {str(e)}", + f"Failed to create optuna storage for study {study_name}: {repr(e)}", exc_info=True, ) return None @@ -1089,7 +1092,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): ) except Exception as e: logger.error( - f"Failed to create optuna study {study_name}: {str(e)}", exc_info=True + f"Failed to create optuna study {study_name}: {repr(e)}", exc_info=True ) return None @@ -1129,7 +1132,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): json.dump(self.get_optuna_params(pair, namespace), write_file, indent=4) except Exception as e: logger.error( - f"Failed to save optuna {namespace} best params for {pair}: {str(e)}", + f"Failed to save optuna {namespace} best params for {pair}: {repr(e)}", exc_info=True, ) raise diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 40bd39e..c55fb30 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -446,7 +446,7 @@ class QuickAdapterV3(IStrategy): try: return pattern.format(**duration) except (KeyError, ValueError) as e: - raise ValueError(f"Invalid pattern '{pattern}': {e}") + raise ValueError(f"Invalid pattern '{pattern}': {repr(e)}") def set_freqai_targets( self, dataframe: DataFrame, metadata: dict[str, Any], **kwargs @@ -691,7 +691,7 @@ class QuickAdapterV3(IStrategy): return trade_kama_natr_values[-1] except Exception as e: logger.warning( - f"Failed to calculate trade NATR KAMA for pair {pair}: {str(e)}. Falling back to last trade NATR value", + f"Failed to calculate trade NATR KAMA for pair {pair}: {repr(e)}. Falling back to last trade NATR value", exc_info=True, ) return label_natr.iloc[-1] @@ -775,7 +775,7 @@ class QuickAdapterV3(IStrategy): callback() except Exception as e: logger.error( - f"Error executing callback for {pair}: {str(e)}", exc_info=True + f"Error executing callback for {pair}: {repr(e)}", exc_info=True ) def custom_stoploss( -- 2.43.0