]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): refine trade entry confirmations boundaries
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Aug 2025 12:24:38 +0000 (14:24 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Aug 2025 12:24:38 +0000 (14:24 +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 a6784cdb8a4b8454c8a952aea1b2932fa14d13e8..15324234f1944dcfebcee2509336e7b76a3eb51e 100644 (file)
@@ -615,8 +615,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     ) -> float:
         values = series.to_numpy()
 
-        if values.size < 2 or np.all(np.isclose(values, values[0])):
-            return values.mean() if values.size > 0 else np.nan
+        if values.size == 0:
+            return np.nan
+        if values.size == 1 or np.all(np.isclose(values, values[0])):
+            return values.mean()
         try:
             return threshold_func(values)
         except Exception:
index 922f5c95dc32705c0a22ab105d86869715e6ba7b..3a6899849b6b18771185e62eefbd6396d9252519 100644 (file)
@@ -65,7 +65,7 @@ class QuickAdapterV3(IStrategy):
     INTERFACE_VERSION = 3
 
     def version(self) -> str:
-        return "3.3.120"
+        return "3.3.121"
 
     timeframe = "5m"
 
@@ -971,15 +971,18 @@ class QuickAdapterV3(IStrategy):
             return False
         lower_bound = 0
         upper_bound = 0
-        price_deviation = (last_candle_natr / 100.0) * self.get_entry_natr_ratio(
-            pair, 0.00075
+        unfavorable_deviation = (last_candle_natr / 100.0) * self.get_entry_natr_ratio(
+            pair, 0.00125
+        )
+        favorable_deviation = (last_candle_natr / 100.0) * self.get_entry_natr_ratio(
+            pair, 0.00225
         )
         if side == "long":
-            lower_bound = last_candle_weighted_close * (1 - 2 * price_deviation)
-            upper_bound = last_candle_weighted_close * (1 + price_deviation)
+            lower_bound = last_candle_weighted_close * (1 - favorable_deviation)
+            upper_bound = last_candle_weighted_close * (1 + unfavorable_deviation)
         elif side == "short":
-            lower_bound = last_candle_weighted_close * (1 - price_deviation)
-            upper_bound = last_candle_weighted_close * (1 + 2 * price_deviation)
+            lower_bound = last_candle_weighted_close * (1 - unfavorable_deviation)
+            upper_bound = last_candle_weighted_close * (1 + favorable_deviation)
         if lower_bound < 0:
             logger.info(
                 f"User denied {side} entry for {pair}: calculated lower bound {lower_bound} is below zero"