From 8729427fc62b0b4498096c6f75db63248597b2a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 1 Aug 2025 23:36:17 +0200 Subject: [PATCH] perf(qav3): make trade entry confirmation boundaries more volatility aware MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../user_data/strategies/QuickAdapterV3.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index e2d429d..40adb8b 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -65,7 +65,7 @@ class QuickAdapterV3(IStrategy): INTERFACE_VERSION = 3 def version(self) -> str: - return "3.3.123" + return "3.3.124" timeframe = "5m" @@ -969,14 +969,37 @@ class QuickAdapterV3(IStrategy): last_candle_natr = last_candle.get("natr_label_period_candles") if isna(last_candle_natr) or last_candle_natr < 0: return False - lower_bound = 0 - upper_bound = 0 + natr_values = df.get("natr_label_period_candles").to_numpy() + label_period_candles = self.get_label_period_candles(pair) + last_candle_natr_quantile = calculate_quantile( + natr_values[-label_period_candles:], last_candle_natr + ) + if isna(last_candle_natr_quantile): + last_candle_natr_quantile = 0.5 + unfavorable_deviation_min_natr_ratio_percent = 0.0025 + unfavorable_deviation_max_natr_ratio_percent = 0.005 unfavorable_deviation = (last_candle_natr / 100.0) * self.get_entry_natr_ratio( - pair, 0.005 + pair, + unfavorable_deviation_min_natr_ratio_percent + + ( + unfavorable_deviation_max_natr_ratio_percent + - unfavorable_deviation_min_natr_ratio_percent + ) + * last_candle_natr_quantile, ) + favorable_deviation_min_natr_ratio_percent = 0.01 + favorable_deviation_max_natr_ratio_percent = 0.025 favorable_deviation = (last_candle_natr / 100.0) * self.get_entry_natr_ratio( - pair, 0.025 + pair, + favorable_deviation_min_natr_ratio_percent + + ( + favorable_deviation_max_natr_ratio_percent + - favorable_deviation_min_natr_ratio_percent + ) + * last_candle_natr_quantile, ) + lower_bound = 0 + upper_bound = 0 if side == "long": lower_bound = last_candle_weighted_close * (1 - favorable_deviation) upper_bound = last_candle_weighted_close * (1 + unfavorable_deviation) -- 2.43.0