diff --git a/Zeus_8_3_2_B_4_2.json b/Zeus_8_3_2_B_4_2.json index 5336188..2692201 100644 --- a/Zeus_8_3_2_B_4_2.json +++ b/Zeus_8_3_2_B_4_2.json @@ -21,11 +21,14 @@ }, "sell": {}, "protection": { - "sma20_deriv1_1d_protection": -0.05, - "sma24_deriv1_1h_protection": -0.1, - "sma5_deriv1_1d_protection": -0.05 + "sma20_deriv1_1d_start_protection": 0.0, + "sma20_deriv1_1d_stop_protection": 0.0, + "sma5_deriv1_1d_start_protection": 0.0, + "sma5_deriv1_1d_stop_protection": 0.0, + "sma5_deriv2_1d_start_protection": 0.0, + "sma5_deriv2_1d_stop_protection": 0.0 } }, "ft_stratparam_v": 1, - "export_time": "2025-09-16 18:26:35.356631+00:00" + "export_time": "2025-09-27 06:44:29.575217+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 624add3..a63cf36 100644 --- a/Zeus_8_3_2_B_4_2.py +++ b/Zeus_8_3_2_B_4_2.py @@ -205,17 +205,24 @@ class Zeus_8_3_2_B_4_2(IStrategy): # factors = [1, 1.1, 1.25, 1.5, 2.0, 3] # thresholds = [2, 5, 10, 20, 30, 50] - factors = [1, 1.25, 1.5, 2.0] - thresholds = [2, 5, 10, 20] + factors = [0.5, 0.75, 1, 1.25, 1.5, 2] + thresholds = [0, 2, 5, 10, 30, 45] trades = list() max_profit_pairs = {} - sma20_deriv1_1d_protection = DecimalParameter(-0.1, 0.0, default=-0.05, decimals=2, space='protection', + sma20_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection', optimize=True, load=True) - sma5_deriv1_1d_protection = DecimalParameter(-0.1, 0.0, default=-0.05, decimals=2, space='protection', + sma5_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection', optimize=True, load=True) - sma24_deriv1_1h_protection = DecimalParameter(-1, 0.0, default=-0.05, decimals=1, space='protection', optimize=True, + sma5_deriv2_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=1, space='protection', optimize=True, + load=True) + + sma20_deriv1_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection', + optimize=True, load=True) + sma5_deriv1_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection', + optimize=True, load=True) + sma5_deriv2_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=1, space='protection', optimize=True, load=True) # sma5_deriv1_1d_protection = DecimalParameter(-0.1, 0.0, default=-0.05, decimals=2, space='protection', optimize=True, load=True) @@ -435,6 +442,25 @@ class Zeus_8_3_2_B_4_2(IStrategy): self.pairs[pair]['current_profit'] = current_profit self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit) + dispo = round(self.wallets.get_available_stake_amount()) + hours_since_first_buy = (current_time - trade.open_date_utc).seconds / 3600.0 + days_since_first_buy = (current_time - trade.open_date_utc).days + hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0 + + if self.pairs[pair]['stop'] and hours % 6 == 0: + self.log_trade( + last_candle=last_candle, + date=current_time, + action="🟠 CURRENT", + dispo=dispo, + pair=pair, + rate=last_candle['close'], + trade_type='', + profit=0, # round(current_profit * trade.stake_amount, 2), + buys='', + stake=0 + ) + if last_candle['sma20_deriv1_1d'] > 0 and last_candle['sma5_deriv1_1d'] > 0 and last_candle[ 'mid_smooth_1h_deriv1'] > 0 \ and last_candle['mid_smooth_1h_deriv2'] > 0: @@ -525,7 +551,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): ) self.printLineLog() df = pd.DataFrame.from_dict(self.pairs, orient='index') - colonnes_a_exclure = ['last_candle', 'last_trade', 'last_palier_index', 'stop', + colonnes_a_exclure = ['last_candle', 'last_trade', 'last_palier_index', 'current_trade', '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'] @@ -555,7 +581,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): sma5 = str(sma5_1d) + ' ' + str(sma5_1h) - last_lost = round((last_candle['close'] - self.pairs[pair]['max_touch']) / self.pairs[pair]['max_touch'], 3) + last_lost = self.getLastLost(last_candle, pair) if buys is None: buys = '' @@ -565,7 +591,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): total_counts = str(buys) + '/' + str(sum(pair_data['count_of_buys'] for pair_data in self.pairs.values())) - dist_max = round(100 * (last_candle['max12_1d'] - last_candle['min12_1d']) / last_candle['min12_1d'], 0) + dist_max = self.getDistMax(last_candle, pair) # if trade_type is not None: # if np.isnan(last_candle['rsi_1d']): @@ -597,11 +623,17 @@ class Zeus_8_3_2_B_4_2(IStrategy): profit = str(round(self.pairs[pair]['current_profit'], 2)) + '/' + str(profit) + # 🟢 Dérivée 1 > 0 et dérivée 2 > 0: tendance haussière qui s’accélère. + # 🟡 Dérivée 1 > 0 et dérivée 2 < 0: tendance haussière qui ralentit → essoufflement potentiel. + # 🔴 Dérivée 1 < 0 et dérivée 2 < 0: tendance baissière qui s’accélère. + # 🟠 Dérivée 1 < 0 et dérivée 2 > 0: tendance baissière qui ralentit → possible bottom. + + # tdc last_candle['tendency_12'] self.printLog( f"| {date:<16} |{action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} |{rate or '-':>9}| {dispo or '-':>6} " f"|{color}{profit or '-':>10}{RESET}| {pct_max or '-':>6} | {round(self.pairs[pair]['max_touch'], 2) or '-':>11} | {last_lost or '-':>12} " f"| {last_max or '-':>7} | {last_min or '-':>7} |{total_counts or '-':>5}|{stake or '-':>7}" - f"|{last_candle['tendency_12'] or '-':>3}|" # {last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}" + f"|{ last_candle['tendency_12'] or '-':>3}|" # {last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}" # f"|{round(last_candle['mid_smooth_24_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_1h_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv1_1d'],3) or '-' :>6}|" # f"{round(last_candle['mid_smooth_24_deriv2'],3) or '-' :>6}|{round(last_candle['mid_smooth_1h_deriv2'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv2_1d'],3) or '-':>6}|" f"{round(val, 1) or '-' :>6}|" @@ -612,6 +644,15 @@ class Zeus_8_3_2_B_4_2(IStrategy): # f"|{last_candle['min60_1d']}|{last_candle['max60_1d']}" ) + def getLastLost(self, last_candle, pair): + last_lost = round((last_candle['close'] - self.pairs[pair]['max_touch']) / self.pairs[pair]['max_touch'], 3) + return last_lost + + def getDistMax(self, last_candle, pair): + mx = last_candle['max12_1d'] + dist_max = round(100 * (mx - last_candle['close']) / mx, 0) + return dist_max + def printLineLog(self): # f"sum1h|sum1d|Tdc|Tdh|Tdd| drv1 |drv_1h|drv_1d|" self.printLog( @@ -1225,7 +1266,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): else: pct = 0.05 - lim = - pct - (count_of_buys * 0.001) + lim = - pct - (count_of_buys * 0.0025) # lim = self.getLimitBuy(pair, last_candle, pct) if (len(dataframe) < 1): @@ -1368,6 +1409,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): # # if count < 3: # return None + last_lost = self.getLastLost(last_candle, pair) max_amount = self.config.get('stake_amount') * 2.5 # stake_amount = min(stake_amount, self.wallets.get_available_stake_amount()) @@ -1515,9 +1557,11 @@ class Zeus_8_3_2_B_4_2(IStrategy): if True: # not pair in ('BTC/USDT', 'BTC/USDC'): # factors = [1, 1.2, 1.3, 1.4] if self.pairs[pair]['count_of_buys'] == 0: - pctClose60 = self.getPctClose60D(pair, last_candle) + # pctClose60 = self.getPctClose60D(pair, last_candle) + dist_max = self.getDistMax(last_candle, pair) + factor = self.multi_step_interpolate(dist_max, self.thresholds, self.factors) - adjusted_stake_amount = max(base_stake_amount / 5, base_stake_amount * (1 - pctClose60)) + adjusted_stake_amount = max(base_stake_amount / 5, base_stake_amount * factor) else: adjusted_stake_amount = self.pairs[pair]['first_amount'] else: @@ -2119,19 +2163,63 @@ class Zeus_8_3_2_B_4_2(IStrategy): limit = 3 + # 🟢 Dérivée 1 > 0 et dérivée 2 > 0: tendance haussière qui s’accélère. + # 🟡 Dérivée 1 > 0 et dérivée 2 < 0: tendance haussière qui ralentit → essoufflement potentiel. + # 🔴 Dérivée 1 < 0 et dérivée 2 < 0: tendance baissière qui s’accélère. + # 🟠 Dérivée 1 < 0 et dérivée 2 > 0: tendance baissière qui ralentit → possible bottom. + + if not pair.startswith('BTC'): + if self.pairs[pair]['stop'] and last_candle['sma5_deriv1_1d'] > self.sma5_deriv1_1d_stop_protection.value \ + and last_candle['sma5_deriv2_1d'] > self.sma5_deriv2_1d_stop_protection.value: + self.pairs[pair]['stop'] = False + self.log_trade( + last_candle=last_candle, + date=current_time, + action="🟢RESTART", + dispo=0, + pair=pair, + rate=last_candle['close'], + trade_type='', + profit=0, # round(current_profit * trade.stake_amount, 2), + buys='', + stake=0 + ) + else: + if self.pairs[pair]['stop'] == False and last_candle['sma5_deriv1_1d'] < - self.sma5_deriv1_1d_start_protection.value \ + and last_candle['sma5_deriv2_1d'] < - self.sma5_deriv2_1d_start_protection.value: + self.pairs[pair]['stop'] = True + self.log_trade( + last_candle=last_candle, + date=current_time, + action="🔴🔴🔴🔴🔴 🔴STOP", + dispo=0, + pair=pair, + rate=last_candle['close'], + trade_type='', + profit=0, # round(current_profit * trade.stake_amount, 2), + buys='', + stake=0 + ) + return False + if self.pairs[pair]['stop']: + return False + if last_candle['sma5_deriv1_1h'] < -0.1: return False + if last_candle['mid_smooth_1h_deriv2'] < -2 or last_candle['sma5_deriv2_1h'] < -2: + return False + if last_candle['sma5_deriv1_1h'] < 0.0 and last_candle['sma5_deriv2_1h'] < -0.0: return False if last_candle['mid_smooth_1h_deriv1'] < 0.0 and last_candle['mid_smooth_1h_deriv2'] < -0.0 and last_candle['sma5_deriv2_1h'] < 0: return False - # if pair.startswith('BTC'): - # return True # BTC toujours autorisé + if pair.startswith('BTC'): + return True # BTC toujours autorisé - return True + #return True # Filtrer les paires non-BTC non_btc_pairs = [p for p in self.pairs if not p.startswith('BTC')] @@ -2166,25 +2254,20 @@ class Zeus_8_3_2_B_4_2(IStrategy): # if (last_candle['mid_smooth_1h_deriv1'] < -0.0 and last_candle['sma24_deriv1_1h'] < -0.0): # return False - if last_candle['sma5_deriv2_1h'] < -0.2: - return False + # if (last_candle['sma5_deriv1_1d'] < -0.1 and last_candle['sma5_deriv2_1d'] < -0) \ + # or last_candle['sma5_deriv2_1d'] < -0.2: + # return False if last_candle['mid_smooth_1h_deriv1'] < -0.02: # and last_candle['mid_smooth_1h_deriv2'] > 0): return False - if self.pairs[pair]['count_of_buys'] >= 3: - if last_candle['sma5_deriv1_1d'] < -0.065 or (last_candle['sma5_deriv1_1d'] < -0.0 and last_candle['sma5_deriv2_1d'] < -0.0): - return False - # if self.pairs[pair]['count_of_buys'] >= 3: - # if (last_candle['sma20_deriv1_1d'] < self.sma20_deriv1_1d_protection.value - # and last_candle['sma5_deriv1_1d'] < self.sma5_deriv1_1d_protection.value \ - # and last_candle['sma24_deriv1_1h'] < self.sma24_deriv1_1h_protection.value): - # # or (last_candle['sma5_deriv1_1d'] < -0.1 and last_candle['sma24_deriv1_1h'] < -0.1): - # return False - - if pair.startswith('BTC'): - return True # BTC toujours autorisé + # if (last_candle['sma20_deriv1_1d'] < self.sma20_deriv1_1d_protection.value + # and last_candle['sma5_deriv1_1d'] < self.sma5_deriv1_1d_protection.value \ + # and last_candle['sma5_deriv2_1d'] < -0.05): + # # or (last_candle['sma5_deriv1_1d'] < -0.1 and last_candle['sma24_deriv1_1h'] < -0.1): + # self.pairs[pair]['stop'] = True + # return False self.should_enter_trade_count = 0