]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(quickadapter): render zero-weight extrema bars
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 24 Dec 2025 12:36:53 +0000 (13:36 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 24 Dec 2025 12:36:53 +0000 (13:36 +0100)
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/QuickAdapterV3.py

index dbb406b1808473bc092aba092ad6202808d9fa73..76a350fa1f492d054146bd349787cfb76f53408f 100644 (file)
@@ -72,7 +72,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.137"
+    version = "3.7.138"
 
     _TEST_SIZE: Final[float] = 0.1
 
index 8cd085d873c70cee18086e5cd01f9f1cf9d89c08..4fb8d9ac739ef3dbf3fc05a3a55bc13752be5bf5 100644 (file)
@@ -107,7 +107,7 @@ class QuickAdapterV3(IStrategy):
     _TRADING_MODES: Final[tuple[TradingMode, ...]] = ("spot", "margin", "futures")
 
     def version(self) -> str:
-        return "3.3.187"
+        return "3.3.188"
 
     timeframe = "5m"
 
@@ -146,6 +146,8 @@ class QuickAdapterV3(IStrategy):
 
     _ANNOTATION_LINE_OFFSET_CANDLES: Final[int] = 10
 
+    _PLOT_EXTREMA_ZERO_EPS: Final[float] = 0.025
+
     timeframe_minutes = timeframe_to_minutes(timeframe)
     minimal_roi = {str(timeframe_minutes * 864): -1}
 
@@ -1110,8 +1112,10 @@ class QuickAdapterV3(IStrategy):
             )
             dataframe.loc[pivots_indices, EXTREMA_COLUMN] = pivots_directions
 
+        extrema_direction = dataframe[EXTREMA_COLUMN]
+
         weighted_extrema, _ = get_weighted_extrema(
-            extrema=dataframe[EXTREMA_COLUMN],
+            extrema=extrema_direction,
             indices=pivots_indices,
             amplitudes=pivots_amplitudes,
             amplitude_threshold_ratios=pivots_amplitude_threshold_ratios,
@@ -1136,8 +1140,17 @@ class QuickAdapterV3(IStrategy):
             gamma=self.extrema_weighting["gamma"],
         )
 
-        dataframe["minima"] = weighted_extrema.clip(upper=0.0)
-        dataframe["maxima"] = weighted_extrema.clip(lower=0.0)
+        plot_eps = QuickAdapterV3._PLOT_EXTREMA_ZERO_EPS
+        dataframe["maxima"] = (
+            weighted_extrema.where(extrema_direction.gt(0), 0.0)
+            .clip(lower=0.0)
+            .mask(extrema_direction.gt(0) & weighted_extrema.eq(0.0), plot_eps)
+        )
+        dataframe["minima"] = (
+            weighted_extrema.where(extrema_direction.lt(0), 0.0)
+            .clip(upper=0.0)
+            .mask(extrema_direction.lt(0) & weighted_extrema.eq(0.0), -plot_eps)
+        )
 
         dataframe[EXTREMA_COLUMN] = smooth_extrema(
             weighted_extrema,