From 7a8a8e1665d24ec629fd67b8cbc797338df99bef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 3 May 2025 21:27:43 +0200 Subject: [PATCH] refactor(qav3): TP code cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../user_data/freqaimodels/QuickAdapterRegressorV3.py | 6 +++--- quickadapter/user_data/strategies/QuickAdapterV3.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 94c78b9..8254abd 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -967,10 +967,10 @@ def label_objective( fit_live_predictions_candles: int, candles_step: int, ) -> tuple[float, int]: - min_label_period_candles: int = round_to_nearest( + min_label_period_candles: int = round_to_nearest_int( max(fit_live_predictions_candles // 16, 20), candles_step ) - max_label_period_candles: int = round_to_nearest( + max_label_period_candles: int = round_to_nearest_int( max(fit_live_predictions_candles // 4, min_label_period_candles), candles_step, ) @@ -1046,7 +1046,7 @@ def boltzmann_operator(series: pd.Series, alpha: float) -> float: return numerator / denominator -def round_to_nearest(value: float, step: int) -> int: +def round_to_nearest_int(value: float, step: int) -> int: """ Round a value to the nearest multiple of a given step. :param value: The value to round. diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index a8a1e01..c9bc56d 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -509,7 +509,6 @@ class QuickAdapterV3(IStrategy): current_natr = df["natr_label_period_candles"].iloc[-1] if isna(current_natr): return None - take_profit_natr_ratio = self.get_take_profit_natr_ratio(trade.pair) natr_change_pct = abs(current_natr - entry_natr) / entry_natr if natr_change_pct > 0.2: if current_natr > entry_natr: @@ -521,13 +520,15 @@ class QuickAdapterV3(IStrategy): else: entry_natr_weight = 0.5 current_natr_weight = 0.5 - blended_take_profit_natr = ( + take_profit_natr = ( entry_natr_weight * entry_natr + current_natr_weight * current_natr ) - take_profit_distance = ( - trade.open_rate * blended_take_profit_natr * take_profit_natr_ratio + return ( + trade.open_rate + * take_profit_natr + * self.get_take_profit_natr_ratio(trade.pair) + * math.log10(9 + trade_duration_candles) ) - return take_profit_distance * math.log10(9 + trade_duration_candles) def custom_stoploss( self, -- 2.43.0