achat sur mid_smooth_deriv1 > 0

This commit is contained in:
Jérôme Delacotte
2025-05-14 17:53:40 +02:00
parent 47851395fa
commit abe4019342

View File

@@ -325,6 +325,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
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)
if (last_candle['mid_smooth_deriv1'] >= 0):
return None
if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80): if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80):
return None return None
@@ -432,7 +434,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
f"| {round(self.pairs[pair]['last_max'], 0) or '-':>7} |{buys or '-':>4}|{stake or '-':>7}" f"| {round(self.pairs[pair]['last_max'], 0) or '-':>7} |{buys or '-':>4}|{stake or '-':>7}"
f"|{round(last_candle['sma5_diff_sum_1h'], 2) or '-':>6}|{round(last_candle['sma5_diff_sum_1d'], 2) or '-':>6}" f"|{round(last_candle['sma5_diff_sum_1h'], 2) or '-':>6}|{round(last_candle['sma5_diff_sum_1d'], 2) or '-':>6}"
f"|{last_candle['tendency'] or '-':>3}|{last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}" f"|{last_candle['tendency'] or '-':>3}|{last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}"
f"|{round(last_candle['mid_smooth_deriv1']) or '-':>3}|{round(last_candle['mid_smooth_deriv1_1h']) or '-':>5}|{round(last_candle['mid_smooth_deriv1_1d']) or '-' :>5}" f"|{round(last_candle['mid_smooth_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv1_1h'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv1_1d'],3) or '-' :>6}"
# f"|{round(last_candle['mid_smooth_deriv2']) or '-' :>3 }|{round(last_candle['mid_smooth_deriv2_1h']) or '-':>5}|{round(last_candle['mid_smooth_deriv2_1d']) or '-':>5}" # f"|{round(last_candle['mid_smooth_deriv2']) or '-' :>3 }|{round(last_candle['mid_smooth_deriv2_1h']) or '-':>5}|{round(last_candle['mid_smooth_deriv2_1d']) or '-':>5}"
) )
@@ -512,10 +514,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe['rsi_diff'] = dataframe['rsi'].diff() dataframe['rsi_diff'] = dataframe['rsi'].diff()
dataframe['rsi_diff_2'] = dataframe['rsi_diff'].diff() dataframe['rsi_diff_2'] = dataframe['rsi_diff'].diff()
dataframe['rsi60'] = talib.RSI(dataframe['close'], timeperiod=60)
dataframe['rsi60_diff'] = dataframe['rsi60'].rolling(60).mean().diff()
dataframe['rsi60_diff2'] = dataframe['rsi60_diff'].rolling(60).mean().diff()
# Bollinger Bands # Bollinger Bands
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe['bb_lowerband'] = bollinger['lower'] dataframe['bb_lowerband'] = bollinger['lower']
@@ -563,6 +561,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
informative['sma5'] = talib.SMA(informative, timeperiod=5) informative['sma5'] = talib.SMA(informative, timeperiod=5)
informative['sma5_diff'] = 100 * informative['sma5'].diff() / informative['sma5'] informative['sma5_diff'] = 100 * informative['sma5'].diff() / informative['sma5']
informative['sma24'] = talib.SMA(informative, timeperiod=24)
informative['sma24_diff'] = 100 * informative['sma24'].diff() / informative['sma24']
informative['sma5_pct'] = 100 * (informative['sma5'] - informative['sma5'].shift(1)) / informative['sma5'] informative['sma5_pct'] = 100 * (informative['sma5'] - informative['sma5'].shift(1)) / informative['sma5']
informative['sma5_diff_sum'] = (informative['sma5_pct'].rolling(5).sum()) / 5 informative['sma5_diff_sum'] = (informative['sma5_pct'].rolling(5).sum()) / 5
informative['sma5_diff2_sum'] = informative['sma5_diff_sum'].diff() informative['sma5_diff2_sum'] = informative['sma5_diff_sum'].diff()
@@ -694,22 +694,15 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe.loc[ dataframe.loc[
( (
# (dataframe['rsi_1h'] < 70) # (dataframe['down_count'].shift(1) < - 1)
# & (dataframe['rsi_diff_1h'] > -5) # & (dataframe['down_count'] == 0)
# (dataframe["bb_width"] > 0.01) (dataframe['mid_smooth_deriv1'] > 0)
(dataframe['down_count'].shift(1) < - 1)
& (dataframe['down_count'] == 0)
# & (dataframe['mid_smooth_deriv1'] <= 0.01)
& (dataframe['mid_smooth_deriv1'] >= -0.01)
# & (dataframe['tendency'] != "B--")
# & (dataframe['tendency'] != "B-")
), ['enter_long', 'enter_tag']] = (1, 'down') ), ['enter_long', 'enter_tag']] = (1, 'down')
dataframe.loc[ dataframe.loc[
( (
(dataframe['low'] < dataframe['min200']) (dataframe['low'] < dataframe['min200'])
& (dataframe['min50'] == dataframe['min50'].shift(3)) & (dataframe['min50'] == dataframe['min50'].shift(3))
#
& (dataframe['tendency'] != "B-") & (dataframe['tendency'] != "B-")
), ['enter_long', 'enter_tag']] = (1, 'low') ), ['enter_long', 'enter_tag']] = (1, 'low')
@@ -740,23 +733,36 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe) dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
last_candle = dataframe.iloc[-1].squeeze() last_candle = dataframe.iloc[-1].squeeze()
last_candle_1 = dataframe.iloc[-2].squeeze()
last_candle_2 = dataframe.iloc[-3].squeeze()
last_candle_3 = dataframe.iloc[-4].squeeze() last_candle_3 = dataframe.iloc[-4].squeeze()
last_candle_previous_1h = dataframe.iloc[-13].squeeze()
# prépare les données # prépare les données
current_time = current_time.astimezone(timezone.utc) current_time = current_time.astimezone(timezone.utc)
open_date = trade.open_date.astimezone(timezone.utc) open_date = trade.open_date.astimezone(timezone.utc)
dispo = round(self.wallets.get_available_stake_amount()) dispo = round(self.wallets.get_available_stake_amount())
days_since_first_buy = (current_time - trade.open_date_utc).days
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0 hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
if (len(dataframe) < 1): if (len(dataframe) < 1):
print("skip dataframe") print("skip dataframe")
return None return None
pair = trade.pair pair = trade.pair
if pair not in ('BTC/USDT', 'BTC/USDC', 'XRP/USDT', 'XRP/USDC', 'ETH/USDT', 'ETH/USDC'): if self.dp.runmode.value in ('dry_run'):
print(f"skip pair {pair}") if pair not in ('BTC/USDT', 'BTC/USDC', 'XRP/USDT', 'XRP/USDC', 'ETH/USDT', 'ETH/USDC'):
return None print(f"skip pair {pair}")
return None
else:
if pair not in ('BTC/USDT', 'BTC/USDC'):
print(f"skip pair {pair}")
return None
count_of_buys = trade.nr_of_successful_entries count_of_buys = trade.nr_of_successful_entries
# if (days_since_first_buy >= 5 and count_of_buys >= 4 and last_candle['sma5_pct_1d'] < 0):
# # print(f"waiting day increase pair {pair}")
# return None
# if 'buy' in last_candle: # if 'buy' in last_candle:
# condition = (last_candle['buy'] == 1) # condition = (last_candle['buy'] == 1)
# else: # else:
@@ -794,7 +800,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
and (last_candle['sma5_diff_sum_1d'] > -1 or count_of_buys <= 9) \ and (last_candle['sma5_diff_sum_1d'] > -1 or count_of_buys <= 9) \
and (pct_max < lim): and (pct_max < lim):
try: try:
# and (last_candle['mid_smooth_deriv1_1h'] > 0 and last_candle['mid_smooth_deriv1_1h'] >= last_candle_previous_1h['mid_smooth_deriv1_1h'])
# and (last_candle['mid_smooth_deriv1_1d'] > -1000 or last_candle['mid_smooth_deriv1_1h'] > 200) \ # and (last_candle['mid_smooth_deriv1_1d'] > -1000 or last_candle['mid_smooth_deriv1_1h'] > 200) \
# and (last_candle['mid_smooth_deriv1_1d'] > -1500) \ # and (last_candle['mid_smooth_deriv1_1d'] > -1500) \
# and not (last_candle['mid_smooth_deriv1_1d'] < - 500 and last_candle['mid_smooth_deriv1_1h'] < 0) \ # and not (last_candle['mid_smooth_deriv1_1d'] < - 500 and last_candle['mid_smooth_deriv1_1h'] < 0) \
@@ -823,6 +829,42 @@ class Zeus_8_3_2_B_4_2(IStrategy):
except Exception as exception: except Exception as exception:
print(exception) print(exception)
return None return None
# if (count_of_buys < limit_buy and pct_max > pct and current_profit > 0.004) \
# and (last_candle['rsi_diff_1h'] >= -5) \
# and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H+')) \
# and (last_candle['mid_smooth_deriv1'] > 0.015):
# try:
#
# # and (last_candle['mid_smooth_deriv1_1d'] > -1000 or last_candle['mid_smooth_deriv1_1h'] > 200) \
# # and (last_candle['mid_smooth_deriv1_1d'] > -1500) \
# # and not (last_candle['mid_smooth_deriv1_1d'] < - 500 and last_candle['mid_smooth_deriv1_1h'] < 0) \
#
# max_amount = self.config.get('stake_amount', 100) * 2.5
# 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])
#
# trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
# self.log_trade(
# last_candle=last_candle,
# date=current_time,
# action="Gain +",
# dispo=dispo,
# pair=trade.pair,
# rate=current_rate,
# trade_type=trade_type,
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
# buys=trade.nr_of_successful_entries + 1,
# stake=round(stake_amount, 2)
# )
# self.pairs[trade.pair]['last_buy'] = current_rate
# self.pairs[trade.pair]['max_touch'] = last_candle['close']
# self.pairs[trade.pair]['last_candle'] = last_candle
# return stake_amount
# except Exception as exception:
# print(exception)
# return None
return None return None
def adjust_stake_amount(self, pair: str, last_candle: DataFrame): def adjust_stake_amount(self, pair: str, last_candle: DataFrame):