Calcul 20250101-20250714 826.648 223.977

This commit is contained in:
Jérôme Delacotte
2025-07-18 23:30:57 +02:00
parent a0143c38e1
commit 2f66ab3be7

View File

@@ -173,9 +173,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
'last_date': 0, 'last_date': 0,
'stop': False, 'stop': False,
'max_profit': 0, 'max_profit': 0,
'last_palier_index': -1, 'last_palier_index': -1
'baisse': 0,
'mx': 0
} }
for pair in ["BTC/USDC", "ETH/USDC", "DOGE/USDC", "XRP/USDC", "SOL/USDC", for pair in ["BTC/USDC", "ETH/USDC", "DOGE/USDC", "XRP/USDC", "SOL/USDC",
"BTC/USDT", "ETH/USDT", "DOGE/USDT", "XRP/USDT", "SOL/USDT"] "BTC/USDT", "ETH/USDT", "DOGE/USDT", "XRP/USDT", "SOL/USDT"]
@@ -192,6 +190,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# Somme Mises 50 100 150 250 350 500 700 950 1300 1750 2350 3150 4200 # Somme Mises 50 100 150 250 350 500 700 950 1300 1750 2350 3150 4200
# baisse 1 2 3 5 7 10 14 19 26 35 47 63 84 # baisse 1 2 3 5 7 10 14 19 26 35 47 63 84
factors = [1, 1.1, 1.25, 1.5, 2.0, 3]
thresholds = [2, 5, 10, 20, 30, 50]
trades = list() trades = list()
max_profit_pairs = {} max_profit_pairs = {}
@@ -335,6 +336,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dispo=dispo, dispo=dispo,
profit=round(trade.calc_profit(rate, amount), 2) profit=round(trade.calc_profit(rate, amount), 2)
) )
self.pairs[pair]['total_amount'] = 0
self.pairs[pair]['count_of_buys'] = 0 self.pairs[pair]['count_of_buys'] = 0
self.pairs[pair]['max_touch'] = 0 self.pairs[pair]['max_touch'] = 0
self.pairs[pair]['last_buy'] = 0 self.pairs[pair]['last_buy'] = 0
@@ -374,15 +376,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
count_of_buys = trade.nr_of_successful_entries count_of_buys = trade.nr_of_successful_entries
baisse = self.pairs[pair]['max_profit'] - current_profit # baisse = self.pairs[pair]['max_profit'] - current_profit
mx = self.pairs[pair]['max_profit'] / 5 # mx = self.pairs[pair]['max_profit'] / 5
self.pairs[pair]['count_of_buys'] = count_of_buys self.pairs[pair]['count_of_buys'] = count_of_buys
self.pairs[pair]['current_profit'] = current_profit self.pairs[pair]['current_profit'] = current_profit
self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit) self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit)
self.pairs[pair]['total_amount'] = 0
self.pairs[pair]['baisse'] = baisse
self.pairs[pair]['mx'] = mx
# if (last_candle['mid_smooth_deriv1'] >= 0): # if (last_candle['mid_smooth_deriv1'] >= 0):
# return None # return None
@@ -391,12 +389,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# #
# if (last_candle['sma20_deriv1'] < 0 and before_last_candle['sma20_deriv1'] >= 0) and (current_profit > expected_profit): # if (last_candle['sma20_deriv1'] < 0 and before_last_candle['sma20_deriv1'] >= 0) and (current_profit > expected_profit):
# return 'Drv_' + str(count_of_buys) # return 'Drv_' + str(count_of_buys)
pair_name = pair.replace("/USDT", '').replace("/USDC", '') pair_name = self.getShortName(pair)
if 1 <= count_of_buys <= 3: if 1 <= count_of_buys <= 3:
if ((before_last_candle_2['mid_smooth_3_deriv1'] <= before_last_candle['mid_smooth_3_deriv1']) if ((before_last_candle_2['mid_smooth_3_deriv1'] <= before_last_candle['mid_smooth_3_deriv1'])
& (before_last_candle['mid_smooth_3_deriv1'] >= last_candle['mid_smooth_3_deriv1'])) \ & (before_last_candle['mid_smooth_3_deriv1'] >= last_candle['mid_smooth_3_deriv1'])) \
and (current_profit > expected_profit): and (current_profit > expected_profit):
return 'Drv3_' + pair_name + '_' + str(count_of_buys) return 'Drv3_' + pair_name + '_' + str(count_of_buys)
if 4 <= count_of_buys <= 6: if 4 <= count_of_buys <= 6:
@@ -420,6 +417,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
self.pairs[pair]['max_touch'] = max(last_candle['haclose'], self.pairs[pair]['max_touch']) self.pairs[pair]['max_touch'] = max(last_candle['haclose'], self.pairs[pair]['max_touch'])
def getShortName(self, pair):
return pair.replace("/USDT", '').replace("/USDC", '')
def informative_pairs(self): def informative_pairs(self):
# get access to all pairs available in whitelist. # get access to all pairs available in whitelist.
pairs = self.dp.current_whitelist() pairs = self.dp.current_whitelist()
@@ -462,7 +463,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
if self.columns_logged % 30 == 0: if self.columns_logged % 30 == 0:
self.printLog( self.printLog(
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} |{'Rate':>8} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>7}|{'Buys':>4}| {'Stake':>5} |" f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} |{'Rate':>8} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>7}|{'Buys':>4}| {'Stake':>5} |"
f"Tdc|{'val':>6}| smooth|smoodrv|Distmax|baisse| mx |" f"Tdc|{'val':>6}| smooth|smoodrv|Distmax|"
) )
self.printLineLog() self.printLineLog()
df = pd.DataFrame.from_dict(self.pairs, orient='index') df = pd.DataFrame.from_dict(self.pairs, orient='index')
@@ -502,7 +503,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
buys = '' buys = ''
max_touch = '' # round(last_candle['max12_1d'], 1) #round(self.pairs[pair]['max_touch'], 1) 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) pct_max = self.getPctFirstBuy(pair, last_candle)
total_counts = str(buys) + '/' + str(sum(pair_data['count_of_buys'] for pair_data in self.pairs.values())) total_counts = str(buys) + '/' + str(sum(pair_data['count_of_buys'] for pair_data in self.pairs.values()))
@@ -530,7 +531,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# 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_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(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}|" f"{round(val, 1) or '-' :>6}|"
f"{round(last_candle['mid_smooth_12'], 4) or '-' :>7}|{round(last_candle['mid_smooth_12_deriv1'], 4) or '-' :>7}|{dist_max:>7}|{round(self.pairs[pair]['baisse'], 3):>7}|{round(self.pairs[pair]['mx'], 4):>7}" f"{round(last_candle['mid_smooth_12'], 4) or '-' :>7}|{round(last_candle['mid_smooth_12_deriv1'], 4) or '-' :>7}|{dist_max:>7}"
) )
def printLineLog(self): def printLineLog(self):
@@ -894,6 +895,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# #
# self.calculateProbabilite2Index(df, futur_cols, indic_1, indic_2) # self.calculateProbabilite2Index(df, futur_cols, indic_1, indic_2)
# if (self.getShortName(pair) == 'BTC'):
# for pct in range(0, 75):
# factor = self.multi_step_interpolate(pct, self.thresholds, self.factors)
# print(f"{pct} => {factor}")
return dataframe return dataframe
def calculateProbabilite2Index(self, df, futur_cols, indic_1, indic_2): def calculateProbabilite2Index(self, df, futur_cols, indic_1, indic_2):
@@ -998,15 +1004,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
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']: if self.pairs[pair]['first_buy']:
pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3) pct_first = self.getPctFirstBuy(pair, last_candle)
pct = 0.012 pct = 0.012
if count_of_buys == 1: if count_of_buys == 1:
pct_max = current_profit pct_max = current_profit
else: else:
if self.pairs[trade.pair]['last_buy']: if self.pairs[trade.pair]['last_buy']:
pct_max = round( pct_max = self.getPctLastBuy(pair, last_candle)
(last_candle['close'] - self.pairs[trade.pair]['last_buy']) / self.pairs[trade.pair]['last_buy'], 4)
else: else:
pct_max = - pct pct_max = - pct
@@ -1244,6 +1249,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
return None return None
def getPctFirstBuy(self, pair, last_candle):
return round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
def getPctLastBuy(self, pair, last_candle):
return round((last_candle['close'] - self.pairs[pair]['last_buy']) / self.pairs[pair]['last_buy'], 4)
def getProbaHausse(self, last_candle): def getProbaHausse(self, last_candle):
value_1 = self.getValuesFromTable(self.ema_volume, last_candle['ema_volume']) value_1 = self.getValuesFromTable(self.ema_volume, last_candle['ema_volume'])
value_2 = self.getValuesFromTable(self.mid_smooth_1h_deriv1, last_candle['mid_smooth_1h_deriv1']) value_2 = self.getValuesFromTable(self.mid_smooth_1h_deriv1, last_candle['mid_smooth_1h_deriv1'])
@@ -1259,8 +1270,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
def adjust_stake_amount(self, pair: str, last_candle: DataFrame): def adjust_stake_amount(self, pair: str, last_candle: DataFrame):
# Calculer le minimum des 14 derniers jours # Calculer le minimum des 14 derniers jours
base_stake_amount = self.config.get('stake_amount') # Montant de base configuré base_stake_amount = self.config.get('stake_amount') # Montant de base configuré
factors = [1, 1.1, 1.25, 1.5, 2.0, 3]
thresholds = [2, 5, 10, 20, 30, 50]
if not pair in ('BTC/USDT', 'BTC/USDC'): if not pair in ('BTC/USDT', 'BTC/USDC'):
# factors = [1, 1.2, 1.3, 1.4] # factors = [1, 1.2, 1.3, 1.4]
@@ -1275,16 +1284,19 @@ class Zeus_8_3_2_B_4_2(IStrategy):
if last_max > 0: if last_max > 0:
pct = 100 * (last_max - first_price) / last_max pct = 100 * (last_max - first_price) / last_max
factor = self.multi_step_interpolate(pct, thresholds, factors) factor = self.multi_step_interpolate(pct, self.thresholds, self.factors)
adjusted_stake_amount = base_stake_amount * factor # max(base_stake_amount, min(100, base_stake_amount * percent_4)) adjusted_stake_amount = base_stake_amount * factor # max(base_stake_amount, min(100, base_stake_amount * percent_4))
# pct = 100 * abs(self.getPctFirstBuy(pair, last_candle))
#
# factor = self.multi_step_interpolate(pct, self.thresholds, self.factors)
return adjusted_stake_amount return adjusted_stake_amount
def expectedProfit(self, pair: str, last_candle: DataFrame): def expectedProfit(self, pair: str, last_candle: DataFrame):
count_of_buys = self.pairs[pair]['count_of_buys'] count_of_buys = self.pairs[pair]['count_of_buys']
pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3) pct_first = self.getPctFirstBuy(pair, last_candle)
expected_profit = max(0.004, abs( expected_profit = max(0.004, abs(
pct_first / 3)) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max) pct_first / 3)) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max)
@@ -1805,29 +1817,23 @@ class Zeus_8_3_2_B_4_2(IStrategy):
limit = 3 limit = 3
if pair.startswith('BTC') or self.pairs[pair]['count_of_buys'] == 0: if pair.startswith('BTC'):
return True # BTC toujours autorisé return True # BTC toujours autorisé
# Filtrer les paires non-BTC # Filtrer les paires non-BTC
non_btc_pairs = [p for p in self.pairs] # if not p.startswith('BTC')] non_btc_pairs = [p for p in self.pairs if not p.startswith('BTC')]
# Compter les positions actives sur les paires non-BTC # Compter les positions actives sur les paires non-BTC
max_nb_trades = 0 max_nb_trades = 0
total_non_btc = 0 total_non_btc = 0
max_pair = '' max_pair = ''
count_decrease = 0
for p in non_btc_pairs: for p in non_btc_pairs:
# dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
# last_candle = dataframe.iloc[-1].squeeze()
# if last_candle['sma5_deriv1_1h'] < -0.5:
# count_decrease += 1
max_nb_trades = max(max_nb_trades, self.pairs[p]['count_of_buys']) max_nb_trades = max(max_nb_trades, self.pairs[p]['count_of_buys'])
if (max_nb_trades == self.pairs[p]['count_of_buys'] and max_nb_trades > limit): if (max_nb_trades == self.pairs[p]['count_of_buys'] and max_nb_trades > limit):
max_pair = p max_pair = p
total_non_btc += self.pairs[p]['count_of_buys'] total_non_btc += self.pairs[p]['count_of_buys']
pct_max = round((last_candle['close'] - self.pairs[pair]['last_buy']) / self.pairs[pair]['last_buy'], 3) pct_max = self.getPctLastBuy(pair, last_candle)
# val = self.getProbaHausse(last_candle) # val = self.getProbaHausse(last_candle)
# if (val < 40): # if (val < 40):
@@ -1842,6 +1848,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
self.should_enter_trade_count = 0 self.should_enter_trade_count = 0
if max_pair != '': if max_pair != '':
return (max_pair == pair and self.pairs[pair]['count_of_buys'] <= 5) or pct_max < - 0.1 return max_pair == pair or pct_max < - 0.25
else: else:
return True return True