From: Jérôme Benoit Date: Fri, 1 Aug 2025 21:36:17 +0000 (+0200) Subject: perf(qav3): make trade entry confirmation boundaries more volatility X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8729427fc62b0b4498096c6f75db63248597b2a8;p=freqai-strategies.git perf(qav3): make trade entry confirmation boundaries more volatility aware Signed-off-by: Jérôme Benoit --- 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)