]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): volatility ajusted pivots labeling confirmation
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 16 Jun 2025 07:36:57 +0000 (09:36 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 16 Jun 2025 07:36:57 +0000 (09:36 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/docker/Dockerfile.custom
quickadapter/docker/Dockerfile.custom
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/QuickAdapterV3.py
quickadapter/user_data/strategies/Utils.py

index e787e8deefcbc7af5624c9918c916bd716958f9d..7c5211cf7d7ec1828d4a628e5fff5345de178afc 100644 (file)
@@ -1,4 +1,4 @@
 FROM freqtradeorg/freqtrade:stable_freqairl
 
-ARG optuna_version=4.3.0
+ARG optuna_version=4.4.0
 RUN pip install --user optuna==${optuna_version} optuna-dashboard
index b6601ad1b97c22afcaa3a25acfed601aba051823..34cf2825ed499dc0d61ada1f5430e21ab1bb9a3f 100644 (file)
@@ -1,4 +1,4 @@
 FROM freqtradeorg/freqtrade:stable_freqai
 
-ARG optuna_version=4.3.0
+ARG optuna_version=4.4.0
 RUN pip install --user optuna==${optuna_version} optuna-integration==${optuna_version} optuna-dashboard
index fca8a2749987fa64b7dee0ec6407923187478869..dd7d97c27791771058bffdb4981e14b6ddc65240 100644 (file)
@@ -50,7 +50,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.91"
+    version = "3.7.92"
 
     @cached_property
     def _optuna_config(self) -> dict:
@@ -1325,7 +1325,18 @@ def zigzag(
             max_window,
         ).astype(int)
 
-    @lru_cache(maxsize=8)
+    def calculate_slopes_ok_threshold(
+        pos: int,
+        min_threshold: float = 0.65,
+        max_threshold: float = 0.75,
+    ) -> float:
+        volatility_quantile = calculate_volatility_quantile(pos)
+        if np.isnan(volatility_quantile):
+            return median([min_threshold, max_threshold])
+
+        return min_threshold + (max_threshold - min_threshold) * volatility_quantile
+
+    @lru_cache(maxsize=4096)
     def calculate_slopes_ok_min_max(slopes_ok_threshold: float) -> tuple[int, int]:
         raw_bound1 = math.ceil(1 / slopes_ok_threshold)
         raw_bound2 = math.ceil(1 / (1 - slopes_ok_threshold))
@@ -1423,7 +1434,6 @@ def zigzag(
         direction: TrendDirection,
         enable_weighting: bool = False,
         min_slope: float = np.finfo(float).eps,
-        slopes_ok_threshold: float = 0.65,
     ) -> bool:
         slope_confirmation_window = calculate_slope_confirmation_window(
             candidate_pivot_pos
@@ -1441,6 +1451,7 @@ def zigzag(
                 )
             )
 
+        slopes_ok_threshold = calculate_slopes_ok_threshold(candidate_pivot_pos)
         min_slopes_ok = calculate_min_slopes_ok(
             candidate_pivot_pos, slopes_ok_threshold
         )
index c404e4af83c0aa8d2c6cc9038688ea6ba9fcfdeb..4a0a81247129aa450cab7c61afea822ac76d25f3 100644 (file)
@@ -64,7 +64,7 @@ class QuickAdapterV3(IStrategy):
     INTERFACE_VERSION = 3
 
     def version(self) -> str:
-        return "3.3.95"
+        return "3.3.96"
 
     timeframe = "5m"
 
index 7fbd6ed7d9aeecfb05402aef320459cd2b143651..2fabfba9b758300f00cbae546263bd57b016b190 100644 (file)
@@ -449,7 +449,18 @@ def zigzag(
             max_window,
         ).astype(int)
 
-    @lru_cache(maxsize=8)
+    def calculate_slopes_ok_threshold(
+        pos: int,
+        min_threshold: float = 0.65,
+        max_threshold: float = 0.75,
+    ) -> float:
+        volatility_quantile = calculate_volatility_quantile(pos)
+        if np.isnan(volatility_quantile):
+            return median([min_threshold, max_threshold])
+
+        return min_threshold + (max_threshold - min_threshold) * volatility_quantile
+
+    @lru_cache(maxsize=4096)
     def calculate_slopes_ok_min_max(slopes_ok_threshold: float) -> tuple[int, int]:
         raw_bound1 = math.ceil(1 / slopes_ok_threshold)
         raw_bound2 = math.ceil(1 / (1 - slopes_ok_threshold))
@@ -547,7 +558,6 @@ def zigzag(
         direction: TrendDirection,
         enable_weighting: bool = False,
         min_slope: float = np.finfo(float).eps,
-        slopes_ok_threshold: float = 0.65,
     ) -> bool:
         slope_confirmation_window = calculate_slope_confirmation_window(
             candidate_pivot_pos
@@ -565,6 +575,7 @@ def zigzag(
                 )
             )
 
+        slopes_ok_threshold = calculate_slopes_ok_threshold(candidate_pivot_pos)
         min_slopes_ok = calculate_min_slopes_ok(
             candidate_pivot_pos, slopes_ok_threshold
         )