From 96a0b0b2b075c21c50a23afa8e522ed138e6d719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Delacotte?= Date: Wed, 29 Oct 2025 21:05:06 +0100 Subject: [PATCH] Zeus_8_3_2_B_4_2 test Sell --- Zeus_8_3_2_B_4_2.json | 33 ++++----- Zeus_8_3_2_B_4_2.py | 169 ++++++++++++++++++++++++------------------ 2 files changed, 110 insertions(+), 92 deletions(-) diff --git a/Zeus_8_3_2_B_4_2.json b/Zeus_8_3_2_B_4_2.json index f39a47e..a4ad4c7 100644 --- a/Zeus_8_3_2_B_4_2.json +++ b/Zeus_8_3_2_B_4_2.json @@ -2,15 +2,18 @@ "strategy_name": "Zeus_8_3_2_B_4_2", "params": { "roi": { - "0": 10 + "0": 0.564, + "567": 0.273, + "2814": 0.12, + "7675": 0 }, "stoploss": { "stoploss": -1.0 }, "trailing": { "trailing_stop": false, - "trailing_stop_positive": 0.254, - "trailing_stop_positive_offset": 0.323, + "trailing_stop_positive": null, + "trailing_stop_positive_offset": 0.0, "trailing_only_offset_is_reached": false }, "max_open_trades": { @@ -18,26 +21,16 @@ }, "buy": { "indic_5m": "mid_smooth_5", - "indic_deriv1_5m": -1.52, - "indic_deriv2_5m": -0.15, - "mise_factor_buy": 0.1, - "mises": 10, - "pct": 0.012, - "pct_inc": 0.005 + "mise_factor_buy": 0.01, + "mises": 5, + "pct": 0.02, + "pct_inc": 0.0028 }, "sell": { - "indic_5m_sell": "mid_smooth_24", - "indic_deriv1_5m_sell": -1.93, - "indic_deriv2_5m_sell": -1.4 + "indic_5m_sell": "sma24" }, - "protection": { - "indic_1d_p": "mid_smooth_24", - "indic_deriv1_1d_p_start": -1.9, - "indic_deriv1_1d_p_stop": 1.1, - "indic_deriv2_1d_p_start": 3.7, - "indic_deriv2_1d_p_stop": -0.9 - } + "protection": {} }, "ft_stratparam_v": 1, - "export_time": "2025-10-26 16:32:08.937921+00:00" + "export_time": "2025-10-29 20:02:20.081550+00:00" } \ No newline at end of file diff --git a/Zeus_8_3_2_B_4_2.py b/Zeus_8_3_2_B_4_2.py index 123f2ec..3248c98 100644 --- a/Zeus_8_3_2_B_4_2.py +++ b/Zeus_8_3_2_B_4_2.py @@ -252,29 +252,29 @@ class Zeus_8_3_2_B_4_2(IStrategy): indicators = {'sma5', 'sma12', 'sma24', 'sma60', 'mid_smooth_3', 'mid_smooth_5', 'mid_smooth_12', 'mid_smooth_24'} - mises = IntParameter(5, 50, default=10, space='buy', optimize=False, load=False) + mises = IntParameter(1, 50, default=10, space='buy', optimize=True, load=True) - pct = DecimalParameter(0.005, 0.05, default=0.012, decimals=3, space='buy', optimize=False, load=False) - pct_inc = DecimalParameter(0.0001, 0.003, default=0.005, decimals=4, space='buy', optimize=False, load=False) + pct = DecimalParameter(0.005, 0.05, default=0.012, decimals=3, space='buy', optimize=True, load=True) + pct_inc = DecimalParameter(0.0001, 0.003, default=0.005, decimals=4, space='buy', optimize=True, load=True) indic_5m = CategoricalParameter(indicators, default="sma60", space='buy') - indic_deriv1_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True) - indic_deriv2_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True) + # indic_deriv1_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True) + # indic_deriv2_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True) # indic_1h = CategoricalParameter(indicators, default="sma60", space='buy') # indic_deriv1_1h = DecimalParameter(-5, 5, default=0, decimals=1, space='buy', optimize=True, load=True) # indic_deriv2_1h = DecimalParameter(-10, 10, default=0, decimals=1, space='buy', optimize=True, load=True) - indic_1d_p = CategoricalParameter(indicators, default="sma60", space='protection') - indic_deriv1_1d_p_stop = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True) - indic_deriv2_1d_p_stop = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True) - indic_deriv1_1d_p_start = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True) - indic_deriv2_1d_p_start = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True) + # indic_1d_p = CategoricalParameter(indicators, default="sma60", space='protection') + # indic_deriv1_1d_p_stop = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True) + # indic_deriv2_1d_p_stop = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True) + # indic_deriv1_1d_p_start = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True) + # indic_deriv2_1d_p_start = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True) indic_5m_sell = CategoricalParameter(indicators, default="sma60", space='sell') - indic_deriv1_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True) - indic_deriv2_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True) + # indic_deriv1_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True) + # indic_deriv2_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True) # indic_deriv1_1h_sell = DecimalParameter(-5, 5, default=0, decimals=1, space='sell', optimize=True, load=True) # indic_deriv2_1h_sell = DecimalParameter(-10, 10, default=0, decimals=1, space='sell', optimize=True, load=True) @@ -515,26 +515,26 @@ class Zeus_8_3_2_B_4_2(IStrategy): pair_name = self.getShortName(pair) # if (current_profit > expected_profit) and last_candle['can_sell']: # return 'Can_' + pair_name + '_' + str(count_of_buys) - trend = last_candle['trend_class_1d'] - if (trend == "BR1" or trend == "BR2") and self.pairs[pair]['has_gain'] == 0: # and (last_candle[f"{indic_5m_sell}_deriv1"] <= indic_deriv1_5m_sell and last_candle[f"{indic_5m_sell}_deriv2"] <= indic_deriv2_5m_sell): - - if (last_candle['max_rsi_12_1h'] > 75) and last_candle['trend_class_1h'] == 'BU1' and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0): - self.pairs[pair]['stop'] = True - self.log_trade( - last_candle=last_candle, - date=current_time, - action="🔴STOP", - dispo=dispo, - pair=pair, - rate=last_candle['close'], - trade_type='', - profit=self.pairs[pair]['current_profit'], - buys=self.pairs[pair]['count_of_buys'], - stake=0 - ) - return "MAX_RSI" - - return None + # trend = last_candle['trend_class_1d'] + # if (trend == "BR1" or trend == "BR2") and self.pairs[pair]['has_gain'] == 0: # and (last_candle[f"{indic_5m_sell}_deriv1"] <= indic_deriv1_5m_sell and last_candle[f"{indic_5m_sell}_deriv2"] <= indic_deriv2_5m_sell): + # + # if (last_candle['max_rsi_12_1h'] > 75) and last_candle['trend_class_1h'] == 'BU1' and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0): + # self.pairs[pair]['stop'] = True + # self.log_trade( + # last_candle=last_candle, + # date=current_time, + # action="🔴STOP", + # dispo=dispo, + # pair=pair, + # rate=last_candle['close'], + # trade_type='', + # profit=self.pairs[pair]['current_profit'], + # buys=self.pairs[pair]['count_of_buys'], + # stake=0 + # ) + # return "MAX_RSI" + # + # return None # if (trend == "BR1" or trend == "BR2") and last_candle[f"{self.indic_5m_sell.value}_deriv1"] <= self.indic_deriv1_5m_sell.value \ # and last_candle[f"{self.indic_5m_sell.value}_deriv2"] <= self.indic_deriv2_5m_sell.value: @@ -957,6 +957,8 @@ class Zeus_8_3_2_B_4_2(IStrategy): dataframe["percent"] = (dataframe["close"] - dataframe["open"]) / dataframe["open"] dataframe["percent3"] = (dataframe["close"] - dataframe["open"].shift(3)) / dataframe["open"].shift(3) + dataframe["percent12"] = (dataframe["close"] - dataframe["open"].shift(12)) / dataframe["open"].shift(12) + dataframe["percent24"] = (dataframe["close"] - dataframe["open"].shift(24)) / dataframe["open"].shift(24) if self.dp.runmode.value in ('backtest'): dataframe['futur_percent'] = 100 * (dataframe['close'].shift(-1) - dataframe['close']) / dataframe['close'] @@ -1229,11 +1231,11 @@ class Zeus_8_3_2_B_4_2(IStrategy): dataframe[tendency_col] = dataframe.apply(tag_by_derivatives, axis=1) - if timeframe == '1h' and verbose and self.dp.runmode.value in ('backtest'): - print("##################") - print(f"# STAT {timeframe} {name}{suffixe}") - print("##################") - self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent'], indic_1=f"{name}{suffixe}_deriv1", indic_2=f"{name}{suffixe}_deriv2") + # if timeframe == '1h' and verbose and self.dp.runmode.value in ('backtest'): + # print("##################") + # print(f"# STAT {timeframe} {name}{suffixe}") + # print("##################") + # self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent'], indic_1=f"{name}{suffixe}_deriv1", indic_2=f"{name}{suffixe}_deriv2") return dataframe @@ -1263,29 +1265,31 @@ class Zeus_8_3_2_B_4_2(IStrategy): # # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) # ), ['enter_long', 'enter_tag']] = (1, 'smth') - dataframe.loc[ - ( - (dataframe['sma24_deriv2'].shift(1) < 0) - & (dataframe['sma24_deriv2'] > 0) - & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) - & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) - & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) - # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) - # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) - ), ['enter_long', 'enter_tag']] = (1, 'invert') - - dataframe.loc[ - ( - (dataframe['sma24_deriv1'] > 0) - & (dataframe['sma60_deriv1'].shift(1) < 0) - & (dataframe['sma60_deriv1'] > 0) - & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) - & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) - & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) - # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) - # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) - ), ['enter_long', 'enter_tag']] = (1, 'raise') - + # dataframe.loc[ + # ( + # (dataframe['sma24_deriv2'].shift(1) < 0) + # & (dataframe['sma24_deriv2'] > 0) + # & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) + # & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) + # & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) + # # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) + # # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) + # & (dataframe[f"sma60_deriv1"] >= -0.2) + # ), ['enter_long', 'enter_tag']] = (1, 'invert') + # + # dataframe.loc[ + # ( + # (dataframe['sma24_deriv1'] > 0) + # & (dataframe['sma60_deriv1'].shift(1) < 0) + # & (dataframe['sma60_deriv1'] > 0) + # & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) + # & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) + # & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) + # # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) + # # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) + # & (dataframe[f"sma60_deriv1"] >= -0.2) + # ), ['enter_long', 'enter_tag']] = (1, 'raise') + # # dataframe.loc[ # ( # (dataframe['sma60_deriv1'].shift(1) < 0) @@ -1295,18 +1299,32 @@ class Zeus_8_3_2_B_4_2(IStrategy): # & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) # # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) # # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) + # & (dataframe[f"sma60_deriv1"] >= -0.2) # ), ['enter_long', 'enter_tag']] = (1, 'stg_inv') + # + # dataframe.loc[ + # ( + # (dataframe['mid_smooth_24'].shift(24) >= dataframe['mid_smooth_24'].shift(12)) + # & (dataframe['mid_smooth_24'].shift(12) <= dataframe['mid_smooth_24']) + # & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) + # & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) + # & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) + # # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) + # & (dataframe[f"sma60_deriv1"] >= -0.2) + # ), ['enter_long', 'enter_tag']] = (1, 'smth3_inv') dataframe.loc[ ( - (dataframe['mid_smooth_3_1h'].shift(24) >= dataframe['mid_smooth_3_1h'].shift(12)) - & (dataframe['mid_smooth_3_1h'].shift(12) <= dataframe['mid_smooth_3_1h']) - & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d'])) - & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value) - & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value) - # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value) - # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value) - ), ['enter_long', 'enter_tag']] = (1, 'smth3_inv') + (dataframe['percent3'] < -0.03) + & (dataframe['percent'] > 0) + ), ['enter_long', 'enter_tag']] = (1, 'pct3') + + dataframe.loc[ + ( + (dataframe[f"{self.indic_5m.value}"].shift(2) >= dataframe[f"{self.indic_5m.value}"].shift(1)) + & (dataframe[f"{self.indic_5m.value}"].shift(1) <= dataframe['sma5']) + & (dataframe[f"sma60_deriv1"] >= -0.2) + ), ['enter_long', 'enter_tag']] = (1, 'sma5') dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan) @@ -1464,6 +1482,15 @@ class Zeus_8_3_2_B_4_2(IStrategy): # (dataframe['mid_smooth_deriv1'] == 0) # & (dataframe['mid_smooth_deriv1'].shift(1) > 0) # ), ['sell', 'exit_long']] = (1, 'sell_sma5_pct_1h') + + # {indic_5m_sell} {indic_deriv1_5m_sell} {indic_deriv2_5m_sell} + dataframe.loc[ + ( + (dataframe[f"{self.indic_5m_sell.value}"].shift(2) < dataframe[f"{self.indic_5m_sell.value}"].shift(1)) + & (dataframe[f"{self.indic_5m_sell.value}"].shift(1) > dataframe[f"{self.indic_5m_sell.value}"]) + & (dataframe[f"sma60_deriv1"] > 0.3) + ), ['exit_long', 'exit_tag']] = (1, 'sma5') + return dataframe def adjust_trade_position(self, trade: Trade, current_time: datetime, @@ -1562,10 +1589,8 @@ class Zeus_8_3_2_B_4_2(IStrategy): # return None max_amount = self.config.get('stake_amount') * 2.5 - # stake_amount = min(stake_amount, self.wallets.get_available_stake_amount()) stake_amount = min(min(max_amount, self.wallets.get_available_stake_amount()), - self.adjust_stake_amount(pair, - last_candle) - 10 * last_lost / self.mise_factor_buy.value) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys]) + self.adjust_stake_amount(pair, last_candle) * abs(last_lost / self.mise_factor_buy.value)) if self.wallets.get_available_stake_amount() > stake_amount: trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48' @@ -1699,7 +1724,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): # Calculer le minimum des 14 derniers jours nb_pairs = len(self.dp.current_whitelist()) - base_stake_amount = self.config.get('stake_amount') #/ (self.mises.value * nb_pairs) # Montant de base configuré + base_stake_amount = self.config.get('stake_amount') / (self.mises.value) # * nb_pairs) # Montant de base configuré # pct60 = round(100 * self.getPctClose60D(pair, last_candle), 2) if True: # not pair in ('BTC/USDT', 'BTC/USDC'):