From 3c47b79bb799e3790d46b45c52fb64c234444025 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 6 May 2025 13:33:21 +0200 Subject: [PATCH] refactor(qav3): cleanup confirm_trade_entry() 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 | 49 +++++-------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 07fadce..60589c5 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -645,45 +645,22 @@ class QuickAdapterV3(IStrategy): return False entry_natr_ratio = self.get_entry_natr_ratio(pair) if side == "long": - lower_bound = ( - last_candle_low - last_candle_low * last_candle_natr * entry_natr_ratio - ) - upper_bound = ( - last_candle_close - + last_candle_close * last_candle_natr * entry_natr_ratio - ) - if lower_bound < 0: - logger.info( - f"User denied {side} entry for {pair}: calculated lower bound {lower_bound} is below zero" - ) - return False - if lower_bound <= rate <= upper_bound: - return True - else: - logger.info( - f"User denied {side} entry for {pair}: rate {rate} outside bounds [{lower_bound}, {upper_bound}]" - ) + lower_bound = last_candle_low * (1 - last_candle_natr * entry_natr_ratio) + upper_bound = last_candle_close * (1 + last_candle_natr * entry_natr_ratio) elif side == "short": - lower_bound = ( - last_candle_close - - last_candle_close * last_candle_natr * entry_natr_ratio + lower_bound = last_candle_close * (1 - last_candle_natr * entry_natr_ratio) + upper_bound = last_candle_high * (1 + last_candle_natr * entry_natr_ratio) + if lower_bound < 0: + logger.info( + f"User denied {side} entry for {pair}: calculated lower bound {lower_bound} is below zero" ) - upper_bound = ( - last_candle_high - + last_candle_high * last_candle_natr * entry_natr_ratio + return False + if lower_bound <= rate <= upper_bound: + return True + else: + logger.info( + f"User denied {side} entry for {pair}: rate {rate} outside bounds [{lower_bound}, {upper_bound}]" ) - if lower_bound < 0: - logger.info( - f"User denied {side} entry for {pair}: calculated lower bound {lower_bound} is below zero" - ) - return False - if lower_bound <= rate <= upper_bound: - return True - else: - logger.info( - f"User denied {side} entry for {pair}: rate {rate} outside bounds [{lower_bound}, {upper_bound}]" - ) - return False def max_open_trades_per_side(self) -> int: -- 2.43.0