From 5b6fedaf138f59b656ce9481e6d359a259bbe887 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 27 Dec 2025 14:32:57 +0100 Subject: [PATCH] refactor: harmonize logging messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../reward_space_analysis/reward_space_analysis.py | 10 +++++----- .../freqaimodels/QuickAdapterRegressorV3.py | 5 +++-- .../user_data/strategies/QuickAdapterV3.py | 14 +++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ReforceXY/reward_space_analysis/reward_space_analysis.py b/ReforceXY/reward_space_analysis/reward_space_analysis.py index a27edef..606110f 100644 --- a/ReforceXY/reward_space_analysis/reward_space_analysis.py +++ b/ReforceXY/reward_space_analysis/reward_space_analysis.py @@ -857,7 +857,7 @@ def _compute_time_attenuation_coefficient( alpha = -math.log(tau) / _LOG_2 else: warnings.warn( - f"Param: exit_power_tau={tau} outside (0,1]; falling back to alpha=1.0", + f"Param: exit_power_tau={tau} outside (0,1]; falling back to 1.0", RewardDiagnosticsWarning, stacklevel=2, ) @@ -905,7 +905,7 @@ def _compute_time_attenuation_coefficient( time_attenuation_coefficient = kernel(effective_dr) except Exception as e: warnings.warn( - f"Param: exit_attenuation_mode='{exit_attenuation_mode}' failed ({e!r}); falling back to linear", + f"Param: exit_attenuation_mode='{exit_attenuation_mode}' failed ({e!r}); falling back to 'linear'", RewardDiagnosticsWarning, stacklevel=2, ) @@ -972,7 +972,7 @@ def _get_exit_factor( if exit_factor_threshold > 0 and np.isfinite(exit_factor_threshold): # noqa: SIM102 if abs(exit_factor) > exit_factor_threshold: warnings.warn( - f"Param: |exit_factor|={abs(exit_factor):.2f} > threshold={exit_factor_threshold:.2f}", + f"Param: |exit_factor|={abs(exit_factor):.6g} > threshold={exit_factor_threshold:.6g}", RewardDiagnosticsWarning, stacklevel=2, ) @@ -1072,7 +1072,7 @@ def _compute_efficiency_coefficient( if efficiency_coefficient < 0.0: if _get_bool_param(params, "check_invariants"): warnings.warn( - f"Param: efficiency_coefficient={efficiency_coefficient:.4f} < 0; falling back to 0.0", + f"Param: efficiency_coefficient={efficiency_coefficient:.6g} < 0; falling back to 0.0", RewardDiagnosticsWarning, stacklevel=2, ) @@ -2734,7 +2734,7 @@ def _validate_bootstrap_results( ci_low, ci_high = lower, upper results[metric] = (mean, ci_low, ci_high) warnings.warn( - f"Stats: bootstrap_ci for '{metric}' degenerate (width={width:.2e}); adjusted to epsilon={epsilon:.1e}", + f"Stats: bootstrap_ci for '{metric}' degenerate (width={width:.6g}); falling back to epsilon={epsilon:.6g}", RewardDiagnosticsWarning, stacklevel=2, ) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index d24e927..e009236 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -535,7 +535,8 @@ class QuickAdapterRegressorV3(BaseRegressionModel): label_weights = self.ft_params.get("label_weights") if label_weights is not None: - logger.info(f" label_weights: {label_weights}") + formatted_label_weights = [format_number(w) for w in label_weights] + logger.info(f" label_weights: [{', '.join(formatted_label_weights)}]") else: logger.info( " label_weights: [1.0, ...] * n_objectives, l1 normalized (default)" @@ -1081,7 +1082,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): self.set_optuna_label_candle(pair) self._optuna_label_candles[pair] = 0 else: - logger.info( + logger.debug( f"[{pair}] Optuna {namespace} callback throttled, still {optuna_label_remaining_candles} candles to go" ) if len(self._optuna_label_incremented_pairs) >= len(self.pairs): diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 48d9475..3d253ba 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -376,7 +376,11 @@ class QuickAdapterV3(IStrategy): logger.info("Extrema Weighting:") logger.info(f" strategy: {self.extrema_weighting['strategy']}") - logger.info(f" source_weights: {self.extrema_weighting['source_weights']}") + formatted_source_weights = { + k: format_number(v) + for k, v in self.extrema_weighting["source_weights"].items() + } + logger.info(f" source_weights: {formatted_source_weights}") logger.info(f" aggregation: {self.extrema_weighting['aggregation']}") logger.info( f" aggregation_normalization: {self.extrema_weighting['aggregation_normalization']}" @@ -1699,7 +1703,7 @@ class QuickAdapterV3(IStrategy): pair=trade.pair, current_time=current_time, callback=lambda: logger.info( - f"Trade {trade.trade_direction} {trade.pair} stage {trade_exit_stage} | " + f"[{trade.pair}] Trade {trade.trade_direction} stage {trade_exit_stage} | " f"Take Profit: {format_number(trade_take_profit_price)}, Rate: {format_number(current_rate)}" ), ) @@ -1717,7 +1721,7 @@ class QuickAdapterV3(IStrategy): initial_trade_partial_stake_amount = trade_partial_stake_amount trade_partial_stake_amount = trade.stake_amount - min_stake logger.info( - f"Trade {trade.trade_direction} {trade.pair} stage {trade_exit_stage} | " + f"[{trade.pair}] Trade {trade.trade_direction} stage {trade_exit_stage} | " f"Partial stake amount adjusted from {format_number(initial_trade_partial_stake_amount)} to {format_number(trade_partial_stake_amount)} to respect min_stake {format_number(min_stake)}" ) return ( @@ -2319,7 +2323,7 @@ class QuickAdapterV3(IStrategy): pair=pair, current_time=current_time, callback=lambda: logger.info( - f"Trade {trade.trade_direction} {trade.pair} stage {trade_exit_stage} | " + f"[{trade.pair}] Trade {trade.trade_direction} stage {trade_exit_stage} | " f"Take Profit: {format_number(trade_take_profit_price)}, Rate: {format_number(current_rate)}" ), ) @@ -2393,7 +2397,7 @@ class QuickAdapterV3(IStrategy): pair=pair, current_time=current_time, callback=lambda: logger.info( - f"Trade {trade.trade_direction} {trade.pair} stage {trade_exit_stage} | " + f"[{trade.pair}] Trade {trade.trade_direction} stage {trade_exit_stage} | " f"Take Profit: {format_number(trade_take_profit_price)}, Rate: {format_number(current_rate)} | " f"Declining: {trade_recent_pnl_declining} " f"(tV:{format_number(t_trade_recent_velocity)}<=-t:{format_number(-t_crit_trade_recent_velocity)}, tA:{format_number(t_trade_recent_acceleration)}<=-t:{format_number(-t_crit_trade_recent_acceleration)})" -- 2.43.0