From: Jérôme Benoit Date: Tue, 6 May 2025 11:33:21 +0000 (+0200) Subject: refactor(qav3): cleanup confirm_trade_entry() X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3c47b79bb799e3790d46b45c52fb64c234444025;p=freqai-strategies.git refactor(qav3): cleanup confirm_trade_entry() Signed-off-by: Jérôme Benoit --- 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: