From f5847ffc259141c21147441edd4db9fd4d3afae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Delacotte?= Date: Wed, 16 Jul 2025 10:24:22 +0200 Subject: [PATCH] test pct_max --- Zeus_8_3_2_B_4_2.py | 65 ++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/Zeus_8_3_2_B_4_2.py b/Zeus_8_3_2_B_4_2.py index 975cc63..234a005 100644 --- a/Zeus_8_3_2_B_4_2.py +++ b/Zeus_8_3_2_B_4_2.py @@ -267,7 +267,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): # if count < 3: # allow_to_buy = False - if not self.should_enter_trade(pair): + if not self.should_enter_trade(pair, last_candle): allow_to_buy = False if allow_to_buy: @@ -488,11 +488,9 @@ class Zeus_8_3_2_B_4_2(IStrategy): buys = '' max_touch = '' # round(last_candle['max12_1d'], 1) #round(self.pairs[pair]['max_touch'], 1) - pct_max = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], - 3) # round(100 * self.pairs[pair]['current_profit'], 1) + pct_max = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3) - total_counts = str(buys) + '/' + str(sum(pair_data['count_of_buys'] for pair_data in - self.pairs.values())) # if not pair in ('BTC/USDT', 'BTC/USDC')) + total_counts = str(buys) + '/' + str(sum(pair_data['count_of_buys'] for pair_data in self.pairs.values())) # if trade_type is not None: # if np.isnan(last_candle['rsi_1d']): @@ -654,6 +652,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): # self.calculeDerivees(informative, 'rsi') # informative['sma5'] = talib.SMA(informative, timeperiod=5) + informative['sma14'] = talib.SMA(informative, timeperiod=14) self.calculeDerivees(informative, 'sma5', factor_1=10, factor_2=1) @@ -982,8 +981,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): pct_first = 0 - total_counts = sum( - pair_data['count_of_buys'] for pair_data in self.pairs.values() if not pair in ('BTC/USDT', 'BTC/USDC')) + total_counts = sum(pair_data['count_of_buys'] for pair_data in self.pairs.values() if not pair in ('BTC/USDT', 'BTC/USDC')) if self.pairs[pair]['first_buy']: pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3) @@ -1011,7 +1009,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): print("skip dataframe") return None - if not self.should_enter_trade(pair): + if not self.should_enter_trade(pair, last_candle): return None # if self.dp.runmode.value in ('dry_run'): @@ -1128,21 +1126,23 @@ class Zeus_8_3_2_B_4_2(IStrategy): # or ((before_last_candle['mid_re_smooth_3_deriv1'] <= 0) & (last_candle['mid_re_smooth_3_deriv1'] >= 0) & (3 <= count_of_buys < 6)) \ # or ((before_last_candle['mid_smooth_1h_deriv1'] <= 0) & (last_candle['mid_smooth_1h_deriv1'] >= 0) & (6 <= count_of_buys)) - limit_buy = 20 + limit_buy = 40 if (count_of_buys < limit_buy) and condition and ( pct_max < lim): # and val > self.buy_val_adjust.value and last_candle['mid_smooth_deriv1_1d'] > - 1): try: + if 6 <= count_of_buys and last_candle['sma24_deriv1_1h'] < 0: + return None # print(f"{trade.pair} current_profit={current_profit} count_of_buys={count_of_buys} pct_first={pct_first:.3f} pct_max={pct_max:.3f} lim={lim:.3f} index={index}") # self.pairs[trade.pair]['last_palier_index'] = index # Appel de la fonction - poly_func, x_future, y_future, count = self.polynomial_forecast( - dataframe['mid_smooth_12'], - window=self.buy_horizon_predict_1h.value * 12, - degree=4) - - if count < 3: - return None + # poly_func, x_future, y_future, count = self.polynomial_forecast( + # dataframe['mid_smooth_12'], + # window=self.buy_horizon_predict_1h.value * 12, + # degree=4) + # + # if count < 3: + # return None max_amount = self.config.get('stake_amount') * 2.5 # stake_amount = min(stake_amount, self.wallets.get_available_stake_amount()) @@ -1170,18 +1170,13 @@ class Zeus_8_3_2_B_4_2(IStrategy): self.pairs[trade.pair]['max_touch'] = last_candle['close'] self.pairs[trade.pair]['last_candle'] = last_candle - # for pair, values in self.pairs.items(): - # print(f"\n{pair}") - # for key, value in values.items(): - # print(f" {key:20}: {value}") - - df = pd.DataFrame.from_dict(self.pairs, orient='index') - colonnes_a_exclure = ['last_candle', 'last_trade', 'last_palier_index', 'stop', - 'trade_info', 'last_date', 'expected_profit', 'last_count_of_buys', 'base_stake_amount', 'stop_buy'] - df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure) - # df_filtered = df_filtered["first_buy", "last_max", "max_touch", "last_sell","last_buy", 'count_of_buys', 'current_profit'] - - print(df_filtered) + # df = pd.DataFrame.from_dict(self.pairs, orient='index') + # colonnes_a_exclure = ['last_candle', 'last_trade', 'last_palier_index', 'stop', + # 'trade_info', 'last_date', 'expected_profit', 'last_count_of_buys', 'base_stake_amount', 'stop_buy'] + # df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure) + # # df_filtered = df_filtered["first_buy", "last_max", "max_touch", "last_sell","last_buy", 'count_of_buys', 'current_profit'] + # + # print(df_filtered) return stake_amount except Exception as exception: @@ -1790,7 +1785,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): print("Moyenne des valeurs par double-tranche :") print(pivot_mean.round(2)) - def should_enter_trade(self, pair: str) -> bool: + def should_enter_trade(self, pair: str, last_candle) -> bool: limit = 3 @@ -1810,17 +1805,9 @@ class Zeus_8_3_2_B_4_2(IStrategy): max_pair = p total_non_btc += self.pairs[p]['count_of_buys'] - this_pair_count = self.pairs[p]['count_of_buys'] - - # if total_non_btc >= 12: - # # print("total_non_btc > 10") - # return False + pct_max = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3) if max_pair != '': - # if this_pair_count >= limit: - # Si une autre paire non-BTC a aussi >3 trades, blocage - # if max_pair == pair: - # print(f"{pair} Cette paire {max_pair} est la seule avec >=3 / {max_nb_trades}") - return max_pair == pair + return max_pair == pair or pct_max < - 0.25 else: return True