]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): thresholding logic for trade entry
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 31 Jul 2025 23:29:14 +0000 (01:29 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 31 Jul 2025 23:29:14 +0000 (01:29 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/QuickAdapterV3.py

index a9986a8b20f1ff991af94eae8ed565e213375aa5..6098d3ac69099a885c2846fe4761b0277698ee92 100644 (file)
@@ -51,7 +51,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.107"
+    version = "3.7.108"
 
     @cached_property
     def _optuna_config(self) -> dict[str, Any]:
@@ -540,19 +540,16 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             "triangle",
             "yen",
         }
-        thresholds_ratio = float(
-            self.freqai_info.get("prediction_thresholds_ratio", 1.0)
-        )
         if thresholds_smoothing == "soft_extremum":
             thresholds_alpha = float(
                 self.freqai_info.get("prediction_thresholds_alpha", 10.0)
             )
             return QuickAdapterRegressorV3.soft_extremum_min_max(
-                pred_extrema, thresholds_ratio, thresholds_alpha
+                pred_extrema, thresholds_alpha
             )
         elif thresholds_smoothing in thresholds_smoothing_methods:
             return QuickAdapterRegressorV3.skimage_min_max(
-                pred_extrema, thresholds_ratio, thresholds_smoothing
+                pred_extrema, thresholds_smoothing
             )
         else:
             raise ValueError(
@@ -560,36 +557,27 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             )
 
     @staticmethod
-    def get_pred_min_max(
-        pred_extrema: pd.Series, ratio: float
-    ) -> tuple[pd.Series, pd.Series]:
-        n_pred_minima = sp.signal.find_peaks(-pred_extrema)[0].size
-        n_pred_maxima = sp.signal.find_peaks(pred_extrema)[0].size
-        n_pred_minima_values = max(1, int(n_pred_minima * ratio))
-        n_pred_maxima_values = max(1, int(n_pred_maxima * ratio))
-
-        sorted_pred_extrema = pred_extrema.sort_values(ascending=True)
-        return sorted_pred_extrema.iloc[
-            :n_pred_minima_values
-        ], sorted_pred_extrema.iloc[-n_pred_maxima_values:]
+    def get_pred_min_max(pred_extrema: pd.Series) -> tuple[pd.Series, pd.Series]:
+        minima_indices = sp.signal.find_peaks(-pred_extrema)[0]
+        maxima_indices = sp.signal.find_peaks(pred_extrema)[0]
+
+        return pred_extrema.iloc[minima_indices], pred_extrema.iloc[maxima_indices]
 
     @staticmethod
     def soft_extremum_min_max(
-        pred_extrema: pd.Series, ratio: float, alpha: float
+        pred_extrema: pd.Series, alpha: float
     ) -> tuple[float, float]:
         pred_minima, pred_maxima = QuickAdapterRegressorV3.get_pred_min_max(
-            pred_extrema, ratio
+            pred_extrema
         )
         return soft_extremum(pred_minima, alpha=-alpha), soft_extremum(
             pred_maxima, alpha=alpha
         )
 
     @staticmethod
-    def skimage_min_max(
-        pred_extrema: pd.Series, ratio: float, method: str
-    ) -> tuple[float, float]:
+    def skimage_min_max(pred_extrema: pd.Series, method: str) -> tuple[float, float]:
         pred_minima, pred_maxima = QuickAdapterRegressorV3.get_pred_min_max(
-            pred_extrema, ratio
+            pred_extrema
         )
 
         method_functions = {
index dbcd2add8f795aa4c6d2423a7367bd00c17be1aa..6bfc6ecd97922a8365afb70bd74de1ddaa8a603f 100644 (file)
@@ -65,7 +65,7 @@ class QuickAdapterV3(IStrategy):
     INTERFACE_VERSION = 3
 
     def version(self) -> str:
-        return "3.3.118"
+        return "3.3.119"
 
     timeframe = "5m"