hyperopt ETH

This commit is contained in:
Jérôme Delacotte
2025-11-06 15:02:48 +01:00
parent bd6699493a
commit d9f947481e
2 changed files with 55 additions and 43 deletions

View File

@@ -59,7 +59,7 @@ def normalize(df):
class Zeus_8_3_2_B_4_2(IStrategy):
levels = [1, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
startup_candle_count = 12 * 24 * 5
# startup_candle_count = 12 * 24 * 5
# ROI table:
minimal_roi = {
@@ -361,12 +361,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
last_candle_3 = dataframe.iloc[-3].squeeze()
# val = self.getProbaHausse144(last_candle)
trend = last_candle['trend_class']
# trend = last_candle['trend_class']
# params = self.loadParamsFor(pair, trend)
indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
indic_deriv1_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv1_5m')
indic_deriv2_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv2_5m')
# indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
# indic_deriv1_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv1_5m')
# indic_deriv2_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv2_5m')
condition = True #(last_candle[f"{indic_5m}_deriv1"] >= indic_deriv1_5m) and (last_candle[f"{indic_5m}_deriv2"] >= indic_deriv2_5m)
@@ -519,11 +519,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
days_since_first_buy = (current_time - trade.open_date_utc).days
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
trend = last_candle['trend_class']
indic_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_5m_sell')
indic_deriv1_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv1_5m_sell')
indic_deriv2_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv2_5m_sell')
# trend = last_candle['trend_class']
#
# indic_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_5m_sell')
# indic_deriv1_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv1_5m_sell')
# indic_deriv2_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv2_5m_sell')
if hours % 4 == 0:
self.log_trade(
@@ -681,8 +681,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
return
if self.columns_logged % 10 == 0:
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}| {'last_max':>7}|{'Buys':>5}| {'Stake':>5} |"
f"{'rsi':>6}|Distmax|s201d|s5_1d|s5_2d|s51h|s52h|smt1h|smt2h|"
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} |{'Rate':>8} | {'Dispo':>6} | {'Profit':>8} "
f"| {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>7}| {'last_max':>7}|{'Buys':>5}| {'Stake':>5} |"
f"{'rsi':>6}|Distmax|s201d|s5_1d|s5_2d|s51h|s52h|smt1h|smt2h|tdc1d|tdc1h"
)
self.printLineLog()
df = pd.DataFrame.from_dict(self.pairs, orient='index')
@@ -765,15 +766,15 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# 🟡 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 saccélère.
# 🟠 Dérivée 1 < 0 et dérivée 2 > 0: tendance baissière qui ralentit → possible bottom.
trend = last_candle['trend_class_1d']
indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
indic_deriv1_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv1_5m')
indic_deriv2_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv2_5m')
indic_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_5m_sell')
indic_deriv1_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv1_5m_sell')
indic_deriv2_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv2_5m_sell')
# trend = last_candle['trend_class_1d']
#
# indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
# indic_deriv1_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv1_5m')
# indic_deriv2_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv2_5m')
#
# indic_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_5m_sell')
# indic_deriv1_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv1_5m_sell')
# indic_deriv2_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv2_5m_sell')
self.printLog(
@@ -790,7 +791,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# f"|{last_candle['min60_1d']}|{last_candle['max60_1d']}"
# f"|{last_candle['mid_smooth_tdc_5_1d'] or '-':>3}|{last_candle['mid_smooth_tdc_5_1h'] or '-':>3}|{last_candle['mid_smooth_tdc_5'] or '-':>3}"
f"|{last_candle['mid_smooth_5_state_1d'] or '-':>3}|{last_candle['mid_smooth_24_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state'] or '-':>3}"
f"|Params {last_candle['trend_class_1d']} {last_candle['trend_class_1h']}" # {indic_5m} {indic_deriv1_5m} {indic_deriv2_5m} {indic_5m_sell} {indic_deriv1_5m_sell} {indic_deriv2_5m_sell}"
f"|{last_candle['trend_class_1d']:>5} {last_candle['trend_class_1h']:>5}" # {indic_5m} {indic_deriv1_5m} {indic_deriv2_5m} {indic_5m_sell} {indic_deriv1_5m_sell} {indic_deriv2_5m_sell}"
)
def getLastLost(self, last_candle, pair):
@@ -1385,6 +1386,13 @@ class Zeus_8_3_2_B_4_2(IStrategy):
& (dataframe['percent'] > 0)
), ['enter_long', 'enter_tag']] = (1, 'pct3')
dataframe.loc[
(
(dataframe["sma24"].shift(2) >= dataframe["sma24"].shift(1))
& (dataframe["sma24"].shift(1) <= dataframe["sma24"])
& (dataframe['percent3_1h'] < -0.03)
), ['enter_long', 'enter_tag']] = (1, 'pct3_1h')
dataframe.loc[
(
(dataframe[f"{self.indic_5m_slope_sup_buy.value}"].shift(2) >= dataframe[f"{self.indic_5m_slope_sup_buy.value}"].shift(1))
@@ -1672,7 +1680,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
if not self.should_enter_trade(pair, last_candle, current_time):
return None
condition = (last_candle['enter_long'] and last_candle['sma5_deriv1'] > 0 and last_candle['hapercent'] > 0 and last_candle['stop_buying'] == False) or (last_candle['percent3'] < -0.03 and last_candle['percent'] > 0)
condition = (last_candle['enter_long'] and last_candle['sma60_deriv1'] > 0 and last_candle['hapercent'] > 0 and last_candle['stop_buying'] == False) \
or last_candle['enter_tag'] == 'pct3' \
or last_candle['enter_tag'] == 'pct3_1h'
# if (self.getShortName(pair) != 'BTC' and count_of_buys > 3):
# condition = before_last_candle_24['mid_smooth_3_1h'] > before_last_candle_12['mid_smooth_3_1h'] and before_last_candle_12['mid_smooth_3_1h'] < last_candle['mid_smooth_3_1h'] #and last_candle['mid_smooth_3_deriv1_1h'] < -1.5
@@ -1705,7 +1715,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
stake_amount = min(min(max_amount, self.wallets.get_available_stake_amount()),
self.adjust_stake_amount(pair, last_candle) * abs(last_lost / self.mise_factor_buy.value))
if self.wallets.get_available_stake_amount() > stake_amount:
if stake_amount > 0:
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
self.pairs[trade.pair]['count_of_buys'] += 1
self.pairs[pair]['total_amount'] += stake_amount
@@ -1744,12 +1754,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# and last_candle['sma60_deriv1'] > 0
and last_candle['max_rsi_12_1h'] < 75
and last_candle['rsi_1d'] < 58
and last_candle['stop_buying'] == False
# and last_candle['mid_smooth_5_deriv1_1d'] > 0
and self.wallets.get_available_stake_amount() > 0
):
try:
self.pairs[pair]['previous_profit'] = profit
stake_amount = self.pairs[pair]['first_amount']
if self.wallets.get_available_stake_amount() > stake_amount:
stake_amount = min(self.wallets.get_available_stake_amount(), self.pairs[pair]['first_amount'])
if stake_amount > 0:
self.pairs[pair]['has_gain'] += 1
trade_type = 'Gain +'