]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): revert commit 81440b2
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 29 Jul 2025 14:19:04 +0000 (16:19 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 29 Jul 2025 14:19:04 +0000 (16:19 +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 5f9d66431f8093f6ac3d88b36d8e6034e23abcf6..937a833c9876b857515d2571a7ac9f6c1023df31 100644 (file)
@@ -50,7 +50,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.97"
+    version = "3.7.98"
 
     @cached_property
     def _optuna_config(self) -> dict[str, Any]:
@@ -518,15 +518,17 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
         fit_live_predictions_candles: int,
         label_period_candles: int,
     ) -> tuple[float, float]:
-        q = float(self.freqai_info.get("prediction_thresholds_quantile", 0.95))
+        temperature = float(
+            self.freqai_info.get("prediction_thresholds_temperature", 300.0)
+        )
         extrema = pred_df.get(EXTREMA_COLUMN).iloc[
             -(
                 max(2, int(fit_live_predictions_candles / label_period_candles))
                 * label_period_candles
             ) :
         ]
-        min_pred = extrema.quantile(q=1 - q)
-        max_pred = extrema.quantile(q=q)
+        min_pred = smoothed_min(extrema, temperature=temperature)
+        max_pred = smoothed_max(extrema, temperature=temperature)
         return min_pred, max_pred
 
     def get_multi_objective_study_best_trial(
@@ -1698,6 +1700,28 @@ def label_objective(
     return np.median(pivots_thresholds), len(pivots_values)
 
 
+def smoothed_max(series: pd.Series, temperature=1.0) -> float:
+    data_array = series.to_numpy()
+    if data_array.size == 0:
+        return np.nan
+    if temperature < 0:
+        raise ValueError("temperature must be non-negative")
+    if np.isclose(temperature, 0):
+        return data_array.max()
+    return sp.special.logsumexp(temperature * data_array) / temperature
+
+
+def smoothed_min(series: pd.Series, temperature=1.0) -> float:
+    data_array = series.to_numpy()
+    if data_array.size == 0:
+        return np.nan
+    if temperature < 0:
+        raise ValueError("temperature must be non-negative")
+    if np.isclose(temperature, 0):
+        return data_array.min()
+    return -sp.special.logsumexp(-temperature * data_array) / temperature
+
+
 def round_to_nearest_int(value: float, step: int) -> int:
     """
     Round a value to the nearest multiple of a given step.
index d3236fe336fef5c59cd735b920c59e8ba8831289..c2af22805c5a77d5debcfd38b59e2eba306d0886 100644 (file)
@@ -65,7 +65,7 @@ class QuickAdapterV3(IStrategy):
     INTERFACE_VERSION = 3
 
     def version(self) -> str:
-        return "3.3.105"
+        return "3.3.106"
 
     timeframe = "5m"