Compare commits

...

2 Commits

Author SHA1 Message Date
Jérôme Delacotte
b8da3af406 SELL 2025-10-03 21:12:31 +02:00
Jérôme Delacotte
1090093735 TEST SELL 2025-10-03 21:09:21 +02:00

View File

@@ -185,7 +185,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
'max_profit': 0,
'last_palier_index': -1,
'total_amount': 0,
'has_gain': 0
'has_gain': 0,
'force_sell': False
}
for pair in ["BTC/USDC", "ETH/USDC", "DOGE/USDC", "XRP/USDC", "SOL/USDC",
"BTC/USDT", "ETH/USDT", "DOGE/USDT", "XRP/USDT", "SOL/USDT"]
@@ -398,6 +399,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dispo=dispo,
profit=round(trade.calc_profit(rate, amount), 2)
)
self.pairs[pair]['force_sell'] = False
self.pairs[pair]['has_gain'] = 0
self.pairs[pair]['current_profit'] = 0
self.pairs[pair]['total_amount'] = 0
@@ -464,14 +466,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
pair=pair,
rate=last_candle['close'],
trade_type='',
profit=0, # round(current_profit * trade.stake_amount, 2),
profit=round(current_profit * trade.stake_amount, 1),
buys='',
stake=0
)
if last_candle['mid_smooth_5_deriv1_1d'] > self.sma5_deriv1_1d_stop_sell.value \
and last_candle['mid_smooth_5_deriv2_1d'] > self.sma5_deriv2_1d_stop_sell.value \
and last_candle['mid_smooth_1h_deriv1'] > self.sma5_deriv1_1h_stop_sell.value \
if last_candle['mid_smooth_1h_deriv1'] > self.sma5_deriv1_1h_stop_sell.value \
and last_candle['mid_smooth_1h_deriv2'] > self.sma5_deriv2_1h_stop_sell.value:
return None
@@ -488,7 +488,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# if 1 <= count_of_buys <= 3:
if last_candle['mid_smooth_1h_deriv1'] < 0 and current_profit > expected_profit:
return 'Drv3_' + pair_name + '_' + str(count_of_buys)
self.pairs[pair]['force_sell'] = False
return 'Drv3_' + pair_name + '_' + str(count_of_buys) + '_' + str(self.pairs[pair]['has_gain'])
# if 4 <= count_of_buys <= 6:
# if ((before_last_candle_2['mid_smooth_12_deriv1'] <= before_last_candle['mid_smooth_12_deriv1'])
@@ -1240,7 +1241,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
if trade.has_open_orders:
# print("skip open orders")
return None
if (self.wallets.get_available_stake_amount() < 50): # or trade.stake_amount >= max_stake:
if (self.wallets.get_available_stake_amount() < 0): # or trade.stake_amount >= max_stake:
return 0
dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
@@ -1333,7 +1334,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# pair=trade.pair,
# rate=current_rate,
# trade_type=trade_type,
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 1),
# buys=trade.nr_of_successful_entries + 1,
# stake=round(stake_amount, 2)
# )
@@ -1362,7 +1363,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# pair=trade.pair,
# rate=current_rate,
# trade_type=trade_type,
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 1),
# buys=trade.nr_of_successful_entries + 1,
# stake=round(stake_amount, 2)
# )
@@ -1415,6 +1416,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
limit_buy = 40
if (count_of_buys < limit_buy) and condition and (pct_max < lim):
try:
if self.pairs[pair]['has_gain']:
self.pairs[pair]['force_sell'] = True;
# if 6 <= count_of_buys:
# if not ((before_last_candle_24['sma24_deriv1_1h'] > before_last_candle_12['sma24_deriv1_1h'])
# & (before_last_candle_12['sma24_deriv1_1h'] < last_candle['sma24_deriv1_1h'])):
@@ -1437,6 +1442,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) - 10 * pct_first / self.mise_factor_buy.value) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys])
if self.wallets.get_available_stake_amount() > stake_amount:
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
@@ -1448,7 +1454,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
pair=trade.pair,
rate=current_rate,
trade_type=trade_type,
profit=round(current_profit, 2), # round(current_profit * trade.stake_amount, 2),
profit=round(current_profit * trade.stake_amount, 1),
buys=trade.nr_of_successful_entries + 1,
stake=round(stake_amount, 2)
)
@@ -1466,6 +1472,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# print(df_filtered)
return stake_amount
return None
except Exception as exception:
# print(exception)
return None
@@ -1478,7 +1485,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# pair=trade.pair,
# rate=current_rate,
# trade_type="Stop loss",
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 1),
# buys=trade.nr_of_successful_entries + 1,
# stake=-trade.stake_amount
# )
@@ -1487,28 +1494,40 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# self.pairs[trade.pair]['last_candle'] = last_candle
# return -trade.stake_amount
if (False and count_of_buys < limit_buy and pct_max > 0.004 and hours > 2 and condition
and last_candle['rsi'] < 65 and last_candle['rsi_deriv1'] > 0):
last_lost = self.getLastLost(last_candle, pair)
if (False and hours > 6 and pct_first < -0.05
and last_candle['sma5_deriv1_1h'] > 0
and last_candle['rsi'] < 65 and last_candle['rsi_1h'] < 65
and last_candle['rsi_deriv1'] > 0 and last_candle['rsi_deriv2'] > 0
and last_candle['mid_smooth_12_deriv1'] > 0
and last_candle['mid_smooth_12_deriv2'] > 0
):
try:
stake_amount = self.pairs[pair]['first_amount'] / 2
if self.wallets.get_available_stake_amount() > stake_amount:
self.pairs[pair]['has_gain'] += 1
stake_amount = self.pairs[pair]['first_amount']
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
trade_type = 'Gain +'
self.pairs[trade.pair]['count_of_buys'] += 1
self.pairs[pair]['total_amount'] += stake_amount
self.log_trade(
last_candle=last_candle,
date=current_time,
action="Gain +",
action="🟡 Gain +",
dispo=dispo,
pair=trade.pair,
rate=current_rate,
trade_type=str(round(pct_max, 4)),
profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
profit=round(current_profit * trade.stake_amount, 1),
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]['max_touch'] = last_candle['close']
self.pairs[trade.pair]['last_candle'] = last_candle
return stake_amount
return None
except Exception as exception:
# print(exception)
return None
@@ -1665,8 +1684,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# if last_candle['close'] < max_60:
# pct_to_max = 0.25 * (max_60 - last_candle['close']) / max_60
# pct_to_max = pct_to_max * (2 - pctClose60)
expected_profit = max(0.004,
pct_to_max) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max)
expected_profit = min(3 * lim, max(lim, pct_to_max)) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max)
# print(
# f"Expected profit price={current_price:.4f} min_max={min_max:.4f} min_14={min_14_days:.4f} max_14={max_14_days:.4f} percent={percent:.4f} expected_profit={expected_profit:.4f}")
@@ -2190,44 +2208,43 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# 🟠 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['mid_smooth_5_deriv1_1d'] > self.sma5_deriv1_1d_restart_protection.value \
and last_candle['mid_smooth_5_deriv2_1d'] > self.sma5_deriv2_1d_restart_protection.value:
dispo = round(self.wallets.get_available_stake_amount())
if self.pairs[pair]['stop'] and last_candle['mid_smooth_5_deriv1_1d'] > -0.9 and last_candle['sma5_deriv1_1h'] > 0:
self.pairs[pair]['stop'] = False
self.log_trade(
last_candle=last_candle,
date=current_time,
action="🟢RESTART",
dispo=0,
dispo=dispo,
pair=pair,
rate=last_candle['close'],
trade_type='',
profit=0, # round(current_profit * trade.stake_amount, 2),
buys='',
profit=0,
buys=self.pairs[pair]['count_of_buys'],
stake=0
)
else:
if self.pairs[pair]['stop'] == False \
and last_candle['mid_smooth_5_deriv1_1d'] < self.sma5_deriv1_1d_stop_protection.value \
and last_candle['mid_smooth_5_deriv2_1d'] < self.sma5_deriv2_1d_stop_protection.value:
if self.pairs[pair]['stop'] == False and last_candle['sma5_deriv1_1h'] < -0.2:
self.pairs[pair]['stop'] = True
self.log_trade(
last_candle=last_candle,
date=current_time,
action="🔴STOP",
dispo=0,
dispo=dispo,
pair=pair,
rate=last_candle['close'],
trade_type='',
profit=0, # round(current_profit * trade.stake_amount, 2),
buys='',
profit=0,
buys=self.pairs[pair]['count_of_buys'],
stake=0
)
return False
if self.pairs[pair]['stop']:
return False
if last_candle['sma5_deriv1_1h'] < -0.1:
if last_candle['sma5_deriv1_1h'] < -0.02:
return False
if last_candle['mid_smooth_1h_deriv2'] < -2 or last_candle['sma5_deriv2_1h'] < -2: