Calcul 20240101-20250514 1189.631 255.232$ => 4,662 max 14mises

This commit is contained in:
Jérôme Delacotte
2025-05-29 20:32:59 +02:00
parent 26e91d1bc7
commit 525916cc15

View File

@@ -482,7 +482,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['sma5_deriv1_1h'], 4) or '-' :>7}|{round(last_candle['mid_smooth_3_deriv1'], 4) or '-' :>7}|" f"{round(last_candle['sma5_deriv1_1h'], 4) or '-' :>7}|{round(last_candle['mid_smooth_1h_deriv1'], 4) or '-' :>7}|"
) )
def printLineLog(self): def printLineLog(self):
@@ -566,9 +566,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
) )
# Normalization # Normalization
# Compter les baisses consécutives
self.calculateDownAndUp(dataframe, limit=0.0001)
# dataframe = self.calculateRegression(dataframe, column='mid_smooth', window=24, degree=4, future_offset=12) # dataframe = self.calculateRegression(dataframe, column='mid_smooth', window=24, degree=4, future_offset=12)
# dataframe = self.calculateRegression(dataframe, column='mid_smooth_24', window=24, degree=4, future_offset=12) # dataframe = self.calculateRegression(dataframe, column='mid_smooth_24', window=24, degree=4, future_offset=12)
@@ -589,14 +586,16 @@ class Zeus_8_3_2_B_4_2(IStrategy):
informative['sma24'] = talib.SMA(informative, timeperiod=24) informative['sma24'] = talib.SMA(informative, timeperiod=24)
self.calculeDerivees(informative, 'sma5') self.calculeDerivees(informative, 'sma5')
self.calculeDerivees(informative, 'sma24') self.calculeDerivees(informative, 'sma24')
# informative["mid_re_smooth"] = self.conditional_smoothing(informative['mid_smooth'].dropna(), threshold=0.0005).dropna()
# self.calculeDerivees(informative, "mid_re_smooth")
# self.calculateDownAndUp(informative, limit=0.0012) # self.calculateDownAndUp(informative, limit=0.0012)
informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5']) # informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5'])
print("##################") # if self.dp.runmode.value in ('backtest'):
print("# STAT HOUR") # print("##################")
print("##################") # print("# STAT HOUR")
self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3') # print("##################")
# self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3')
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True) dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True)
@@ -618,10 +617,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5']) informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5'])
print("##################") # if self.dp.runmode.value in ('backtest'):
print("# STAT DAY") # print("##################")
print("##################") # print("# STAT DAY")
self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3') # print("##################")
# self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3')
# informative['close_smooth'] = self.conditional_smoothing(informative['mid'].dropna(), threshold=0.0015).dropna() # informative['close_smooth'] = self.conditional_smoothing(informative['mid'].dropna(), threshold=0.0015).dropna()
# informative['smooth'], informative['deriv1'], informative['deriv2'] = self.smooth_and_derivatives(informative['close_smooth']) # informative['smooth'], informative['deriv1'], informative['deriv2'] = self.smooth_and_derivatives(informative['close_smooth'])
@@ -671,6 +671,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe["mid_smooth_1h_deriv1"] = 100 * dataframe["mid_smooth_1h"].diff() / dataframe['mid_smooth_1h'] dataframe["mid_smooth_1h_deriv1"] = 100 * dataframe["mid_smooth_1h"].diff() / dataframe['mid_smooth_1h']
dataframe["mid_smooth_1h_deriv2"] = 10 * dataframe["mid_smooth_1h_deriv1"].diff() dataframe["mid_smooth_1h_deriv2"] = 10 * dataframe["mid_smooth_1h_deriv1"].diff()
# Compter les baisses / hausses consécutives
self.calculateDownAndUp(dataframe, limit=0.0001)
# dataframe["mid_re_smooth_1h"] = self.conditional_smoothing(dataframe['mid_smooth_1h'].dropna(), threshold=0.0005).dropna()
# self.calculeDerivees(dataframe, "mid_re_smooth_1h")
# dataframe['close_smooth_1h'] = self.conditional_smoothing(dataframe['mid'].rolling(window=3).mean().dropna(), threshold=0.0005) # dataframe['close_smooth_1h'] = self.conditional_smoothing(dataframe['mid'].rolling(window=3).mean().dropna(), threshold=0.0005)
# dataframe['smooth_1h'], dataframe['deriv1_1h'], dataframe['deriv2_1h'] = self.smooth_and_derivatives(dataframe['close_smooth_1h']) # dataframe['smooth_1h'], dataframe['deriv1_1h'], dataframe['deriv2_1h'] = self.smooth_and_derivatives(dataframe['close_smooth_1h'])
# dataframe['deriv1_1h'] = 100 * dataframe['deriv1_1h'] / dataframe['mid_smooth_1h'] # dataframe['deriv1_1h'] = 100 * dataframe['deriv1_1h'] / dataframe['mid_smooth_1h']
@@ -703,7 +709,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# dataframe["mid_smooth_deriv1_1d"] = dataframe["mid_smooth_1d"].rolling(horizon_d).mean().diff() / horizon_d # dataframe["mid_smooth_deriv1_1d"] = dataframe["mid_smooth_1d"].rolling(horizon_d).mean().diff() / horizon_d
# dataframe["mid_smooth_deriv2_1d"] = horizon_d * dataframe["mid_smooth_deriv1_1d"].rolling(horizon_d).mean().diff() # dataframe["mid_smooth_deriv2_1d"] = horizon_d * dataframe["mid_smooth_deriv1_1d"].rolling(horizon_d).mean().diff()
# #
dataframe['sma5_1d'] = dataframe['sma5_1d'].rolling(window=horizon_d).mean() # dataframe['sma5_1d'] = dataframe['sma5_1d'].rolling(window=horizon_d).mean()
# dataframe['sma5_deriv1_1d'] = dataframe['sma5_deriv1_1d'].rolling(window=horizon_d).mean() # dataframe['sma5_deriv1_1d'] = dataframe['sma5_deriv1_1d'].rolling(window=horizon_d).mean()
# dataframe['sma24_1d'] = dataframe['sma24_1d'].rolling(window=horizon_d).mean() # dataframe['sma24_1d'] = dataframe['sma24_1d'].rolling(window=horizon_d).mean()
# dataframe['sma24_deriv1_1d'] = dataframe['sma24_deriv1_1d'].rolling(window=horizon_d).mean() # dataframe['sma24_deriv1_1d'] = dataframe['sma24_deriv1_1d'].rolling(window=horizon_d).mean()
@@ -723,10 +729,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# #
# self.calculateProbabilite2Index(dataframe, ['futur_percent_1d'], 'sma24_deriv1_1h', 'sma5_1d') # self.calculateProbabilite2Index(dataframe, ['futur_percent_1d'], 'sma24_deriv1_1h', 'sma5_1d')
print("##################") # if self.dp.runmode.value in ('backtest'):
print("# STAT DAY vs HOUR") # print("##################")
print("##################") # print("# STAT DAY vs HOUR")
self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent_3_1h'], indic_1='sma5_deriv1_1h', indic_2='mid_smooth_3_deriv1') # print("##################")
# self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent_3_1h'], indic_1='sma5_deriv1_1h', indic_2='mid_smooth_3_deriv1')
return dataframe return dataframe
@@ -735,8 +742,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe[f"{indic}_deriv2"] = factor_2 * dataframe[f"{indic}_deriv1"].diff() dataframe[f"{indic}_deriv2"] = factor_2 * dataframe[f"{indic}_deriv1"].diff()
def calculateDownAndUp(self, dataframe, limit=0.0001): def calculateDownAndUp(self, dataframe, limit=0.0001):
dataframe['down'] = dataframe['hapercent'] <= limit dataframe['down'] = dataframe['mid_smooth_1h_deriv1'] < limit #dataframe['hapercent'] <= limit
dataframe['up'] = dataframe['hapercent'] >= limit dataframe['up'] = dataframe['mid_smooth_1h_deriv1'] > limit #dataframe['hapercent'] >= limit
dataframe['down_count'] = - dataframe['down'].astype(int) * ( dataframe['down_count'] = - dataframe['down'].astype(int) * (
dataframe['down'].groupby((dataframe['down'] != dataframe['down'].shift()).cumsum()).cumcount() + 1) dataframe['down'].groupby((dataframe['down'] != dataframe['down'].shift()).cumsum()).cumcount() + 1)
dataframe['up_count'] = dataframe['up'].astype(int) * ( dataframe['up_count'] = dataframe['up'].astype(int) * (
@@ -794,7 +801,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan) dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
self.paliers = self.get_dca_stakes() # self.paliers = self.get_dca_stakes()
if self.dp.runmode.value in ('backtest'): if self.dp.runmode.value in ('backtest'):
today = datetime.now().strftime("%Y-%m-%d-%H:%M:%S") today = datetime.now().strftime("%Y-%m-%d-%H:%M:%S")
@@ -1062,8 +1069,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
stake_amount = min(min(max_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 * pct_first / pct) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys]) self.adjust_stake_amount(pair, last_candle) - 10 * pct_first / pct) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys])
self.pairs[trade.pair]['count_of_buys'] = self.pairs[trade.pair]['count_of_buys'] + 1
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48' trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
self.pairs[trade.pair]['count_of_buys'] += 1
self.log_trade( self.log_trade(
last_candle=last_candle, last_candle=last_candle,
date=current_time, date=current_time,
@@ -1622,7 +1629,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# Afficher les prédictions # Afficher les prédictions
# print(f"{current} → t+{future_step}: x={future_x}, y={prediction:.2f}") # print(f"{current} → t+{future_step}: x={future_x}, y={prediction:.2f}")
if prediction > current: if prediction > 0: #current:
count += 1 count += 1
return poly, x_future, y_future, count return poly, x_future, y_future, count