]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): validate tunables main
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 25 Oct 2025 17:29:39 +0000 (19:29 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 25 Oct 2025 17:29:39 +0000 (19:29 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
README.md
quickadapter/user_data/strategies/QuickAdapterV3.py

index 6ab09c146a97e4565c7418c938681d36f26eea68..37525834ea45bf0982fc762eb0688537542e4980 100644 (file)
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ docker compose up -d --build
 | _Reversal confirmation_ |                  |  |                                                                                 |
 | reversal_confirmation.lookback_period | 0                | int >= 0 | Prior confirming candles; 0 = none.                                             |
 | reversal_confirmation.decay_ratio | 0.5              | float (0,1] | Geometric per-candle relaxation factor.                                           |
-| reversal_confirmation.min_natr_ratio_percent | 0.009           | float [0,1] | Lower bound fraction for volatility adjusted reversal threshold.                          |
+| reversal_confirmation.min_natr_ratio_percent | 0.0099          | float [0,1] | Lower bound fraction for volatility adjusted reversal threshold.                          |
 | reversal_confirmation.max_natr_ratio_percent | 0.035           | float [0,1] | Upper bound fraction (>= lower bound) for volatility adjusted reversal threshold.         |
 | _Regressor model_ |                  |  |                                                                                 |
 | freqai.regressor | `xgboost`        | enum {`xgboost`,`lightgbm`} | Machine learning regressor algorithm.                                           |
index 1e79bc999e4143849ad3aba0fab04877c2bf41cd..8437cd247c4174d668a569e1d10b43db5e8c98b9 100644 (file)
@@ -98,7 +98,7 @@ class QuickAdapterV3(IStrategy):
     default_reversal_confirmation: dict[str, int | float] = {
         "lookback_period": 0,
         "decay_ratio": 0.5,
-        "min_natr_ratio_percent": 0.009,
+        "min_natr_ratio_percent": 0.0099,
         "max_natr_ratio_percent": 0.035,
     }
 
@@ -1233,8 +1233,16 @@ class QuickAdapterV3(IStrategy):
             return False
         if order not in {"entry", "exit"}:
             return False
-
         trade_direction = side
+        if (
+            min_natr_ratio_percent < 0.0
+            or max_natr_ratio_percent < min_natr_ratio_percent
+        ):
+            logger.warning(
+                f"User denied {trade_direction} {order} for {pair}: invalid natr_ratio_percent range "
+                f"min={format_number(min_natr_ratio_percent)}, max={format_number(max_natr_ratio_percent)}"
+            )
+            return False
 
         if not isinstance(lookback_period, int):
             logger.info(