From d30e81e4562170579dc512c5e541a194d972d73b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 15 Dec 2025 19:46:10 +0100 Subject: [PATCH] fix(qav3): plot extrema bars with normalized weights --- quickadapter/user_data/strategies/QuickAdapterV3.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 9ee2965..3be9bd2 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -995,19 +995,15 @@ class QuickAdapterV3(IStrategy): label_period = datetime.timedelta( minutes=len(dataframe) * timeframe_to_minutes(self.config.get("timeframe")) ) - dataframe[EXTREMA_COLUMN] = 0 + dataframe[EXTREMA_COLUMN] = 0.0 + dataframe["minima"] = 0.0 + dataframe["maxima"] = 0.0 if len(pivots_indices) == 0: logger.warning( f"{pair}: no extrema to label (label_period={QuickAdapterV3._td_format(label_period)} / {label_period_candles=} / {label_natr_ratio=:.2f})" ) else: dataframe.loc[pivots_indices, EXTREMA_COLUMN] = pivots_directions - dataframe["minima"] = np.where( - dataframe[EXTREMA_COLUMN] == TrendDirection.DOWN, -1, 0 - ) - dataframe["maxima"] = np.where( - dataframe[EXTREMA_COLUMN] == TrendDirection.UP, 1, 0 - ) logger.info( f"{pair}: labeled {len(pivots_indices)} extrema (label_period={QuickAdapterV3._td_format(label_period)} / {label_period_candles=} / {label_natr_ratio=:.2f})" ) @@ -1037,6 +1033,9 @@ class QuickAdapterV3(IStrategy): gamma=self.extrema_weighting["gamma"], ) + dataframe["minima"] = weighted_extrema.clip(upper=0.0) + dataframe["maxima"] = weighted_extrema.clip(lower=0.0) + dataframe[EXTREMA_COLUMN] = smooth_extrema( weighted_extrema, self.extrema_smoothing["method"], -- 2.43.0