]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): plot extrema bars with normalized weights
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Dec 2025 18:46:10 +0000 (19:46 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Dec 2025 18:46:10 +0000 (19:46 +0100)
quickadapter/user_data/strategies/QuickAdapterV3.py

index 9ee2965bf38ee0e5a17b371c85675fef222fde79..3be9bd2fbb4dada1f46e51906d18d62b72d45d4b 100644 (file)
@@ -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"],