]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3)!: sensible tunables namespace
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 21 Nov 2025 09:29:35 +0000 (10:29 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 21 Nov 2025 09:29:35 +0000 (10:29 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
README.md
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/Utils.py

index 2604725a4cef8c33b8702d4965301620958ec568..804b28989154465d6ddaae0d1fc3cf691d907b2b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ docker compose up -d --build
 | freqai.extrema_smoothing.window                      | 5                 | int >= 3                                                                                                                         | Window size for extrema smoothing.                                                                                                                                                                         |
 | freqai.extrema_smoothing.beta                        | 8.0               | float > 0                                                                                                                        | Kaiser kernel shape parameter.                                                                                                                                                                             |
 | _Extrema weighting_                                  |                   |                                                                                                                                  |                                                                                                                                                                                                            |
-| freqai.extrema_weighting.strategy                    | `none`            | enum {`none`,`pivot_threshold`}                                                                                                  | Weighting strategy applied before smoothing.                                                                                                                                                               |
+| freqai.extrema_weighting.strategy                    | `none`            | enum {`none`,`threshold`}                                                                                                        | Weighting strategy applied before smoothing.                                                                                                                                                               |
 | freqai.extrema_weighting.normalization               | `minmax`          | enum {`minmax`,`l1`,`none`}                                                                                                      | Normalization method for weights.                                                                                                                                                                          |
 | freqai.extrema_weighting.gamma                       | 1.0               | float (0,10]                                                                                                                     | Contrast exponent applied after normalization (>1 emphasizes extremes, 0<gamma<1 softens).                                                                                                                 |
 | _Feature parameters_                                 |                   |                                                                                                                                  |                                                                                                                                                                                                            |
@@ -79,7 +79,7 @@ docker compose up -d --build
 | freqai.feature_parameters.label_knn_p_order          | `None`            | float                                                                                                                            | p-order for KNN Minkowski metric distance. (optional)                                                                                                                                                      |
 | freqai.feature_parameters.label_knn_n_neighbors      | 5                 | int >= 1                                                                                                                         | Number of neighbors for KNN.                                                                                                                                                                               |
 | _Predictions extrema_                                |                   |                                                                                                                                  |                                                                                                                                                                                                            |
-| freqai.predictions_extrema.selection_method          | `extrema_rank`    | enum {`peak_values`,`extrema_rank`,`partition`}                                                                                  | Extrema selection method. `peak_values` uses detected peaks, `extrema_rank` uses ranked extrema values, `partition` uses sign-based extrema partitioning.                                                  |
+| freqai.predictions_extrema.selection_method          | `rank`            | enum {`values`,`rank`,`partition`}                                                                                               | Extrema selection method. `values` uses reversal values, `rank` uses ranked extrema values, `partition` uses sign-based partitioning.                                                                      |
 | freqai.predictions_extrema.thresholds_smoothing      | `mean`            | enum {`mean`,`median`,`isodata`,`li`,`minimum`,`otsu`,`triangle`,`yen`,`soft_extremum`}                                          | Thresholding method for prediction thresholds smoothing.                                                                                                                                                   |
 | freqai.predictions_extrema.thresholds_alpha          | 12.0              | float > 0                                                                                                                        | Alpha for `soft_extremum`.                                                                                                                                                                                 |
 | freqai.predictions_extrema.threshold_outlier         | 0.999             | float (0,1)                                                                                                                      | Quantile threshold for predictions outlier filtering.                                                                                                                                                      |
index 007d580376e07f5e4922359fcc4d98956d88ec43..a1e1e6e62f63f490f8ec0fa21c43a9730fc21f47 100644 (file)
@@ -33,7 +33,7 @@ from Utils import (
     zigzag,
 )
 
-ExtremaSelectionMethod = Literal["peak_values", "extrema_rank", "partition"]
+ExtremaSelectionMethod = Literal["values", "rank", "partition"]
 OptunaNamespace = Literal["hp", "train", "label"]
 CustomThresholdMethod = Literal["median", "soft_extremum"]
 SkimageThresholdMethod = Literal[
@@ -76,8 +76,8 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     _SQRT_2: Final[float] = np.sqrt(2.0)
 
     _EXTREMA_SELECTION_METHODS: Final[tuple[ExtremaSelectionMethod, ...]] = (
-        "peak_values",
-        "extrema_rank",
+        "values",
+        "rank",
         "partition",
     )
     _CUSTOM_THRESHOLD_METHODS: Final[tuple[CustomThresholdMethod, ...]] = (
@@ -812,7 +812,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
         if pred_extrema.empty:
             return pd.Series(dtype=float), pd.Series(dtype=float)
 
-        if extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[0]:
+        if (
+            extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[0]
+        ):  # "values"
             minima_indices = sp.signal.find_peaks(-pred_extrema)[0]
             maxima_indices = sp.signal.find_peaks(pred_extrema)[0]
 
@@ -826,7 +828,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                 if maxima_indices.size > 0
                 else pd.Series(dtype=float)
             )
-        elif extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[1]:
+        elif (
+            extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[1]
+        ):  # "rank"
             minima_indices = sp.signal.find_peaks(-pred_extrema)[0]
             maxima_indices = sp.signal.find_peaks(pred_extrema)[0]
 
@@ -842,7 +846,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                 pred_maxima = pred_extrema.nlargest(n_maxima)
             else:
                 pred_maxima = pd.Series(dtype=float)
-        elif extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[2]:
+        elif (
+            extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[2]
+        ):  # "partition"
             eps = np.finfo(float).eps
 
             pred_maxima = pred_extrema[pred_extrema > eps]
index f444d7ae41e0f45ec7d80724df98192e075c83fd..50023dcbcf49523caf9c96c078de67524e2bf66c 100644 (file)
@@ -18,8 +18,8 @@ from technical import qtpylib
 T = TypeVar("T", pd.Series, float)
 
 
-WeightStrategy = Literal["none", "pivot_threshold"]
-WEIGHT_STRATEGIES: Final[tuple[WeightStrategy, ...]] = ("none", "pivot_threshold")
+WeightStrategy = Literal["none", "threshold"]
+WEIGHT_STRATEGIES: Final[tuple[WeightStrategy, ...]] = ("none", "threshold")
 
 NormalizationType = Literal["minmax", "l1", "none"]
 NORMALIZATION_TYPES: Final[tuple[NormalizationType, ...]] = ("minmax", "l1", "none")
@@ -259,7 +259,7 @@ def get_weighted_extrema(
     ):  # "none"
         return extrema, default_weights
 
-    if strategy == WEIGHT_STRATEGIES[1]:  # "pivot_threshold"
+    if strategy == WEIGHT_STRATEGIES[1]:  # "threshold"
         extrema_weights = calculate_extrema_weights(
             series=extrema,
             indices=indices,