]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): revert thresholding logic change
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Aug 2025 00:06:38 +0000 (02:06 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Aug 2025 00:06:38 +0000 (02:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index 6098d3ac69099a885c2846fe4761b0277698ee92..a6784cdb8a4b8454c8a952aea1b2932fa14d13e8 100644 (file)
@@ -558,10 +558,13 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
 
     @staticmethod
     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]
+        n_pred_minima = max(1, sp.signal.find_peaks(-pred_extrema)[0].size)
+        n_pred_maxima = max(1, sp.signal.find_peaks(pred_extrema)[0].size)
 
-        return pred_extrema.iloc[minima_indices], pred_extrema.iloc[maxima_indices]
+        sorted_pred_extrema = pred_extrema.sort_values(ascending=True)
+        return sorted_pred_extrema.iloc[:n_pred_minima], sorted_pred_extrema.iloc[
+            -n_pred_maxima:
+        ]
 
     @staticmethod
     def soft_extremum_min_max(