┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓

┃ Strategy ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃    Avg Duration ┃  Win  Draw  Loss  Win% ┃            Drawdown ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│    Empty │     53 │         1.76 │        1312.665 │       131.27 │ 4 days, 1:16:00 │   33     0    20  62.3 │ 116.751 USDT  7.37% │
└──────────┴────────┴──────────────┴─────────────────┴──────────────┴─────────────────┴────────────────────────┴─────────────────────┘
This commit is contained in:
Jérôme Delacotte
2026-02-26 19:44:39 +01:00
parent 2c79bc706e
commit 0250e30e57
3 changed files with 200 additions and 146 deletions

View File

@@ -550,9 +550,14 @@ class Empty(IStrategy):
and (last_candle['sma12_deriv1_1d'] < 0.001 \
or last_candle['sma12_deriv2_1d'] < 0.001) else True
if condition and last_candle['range_pos'] > 0.05:# and self.pairs[pair]['force_stop']:
condition = last_candle['sma5'] > last_candle['sma60']
reason = ''
if not condition:
reason = 'lost'
if condition:
if last_candle['range_pos'] > 0.05:# and self.pairs[pair]['force_stop']:
condition = last_candle['sma5'] > last_candle['sma60']
if not condition:
reason = 'range'
# if self.pairs[pair]['force_stop'] and last_candle['range_pos'] < 0.02:
# self.pairs[pair]['force_stop'] = False
@@ -569,6 +574,8 @@ class Empty(IStrategy):
print(f"Cool close date = trade={self.pairs[pair]['last_trade'].close_date} down {round(self.pairs[pair]['last_profit'], 3)} {cooldown_candles} {candles_since_close}")
# self.should_enter_trade(pair, last_candle, current_time)
if self.pairs[pair]['stop']:
reason = 'stop'
allow_to_buy = (condition and not self.pairs[pair]['stop']) | (entry_tag == 'force_entry')
# force = self.pairs[pair]['force_buy']
@@ -578,6 +585,7 @@ class Empty(IStrategy):
# else:
# if not self.should_enter_trade(pair, last_candle, current_time):
# allow_to_buy = False
dispo = round(self.wallets.get_available_stake_amount())
if allow_to_buy:
self.pairs[pair]['first_buy'] = rate
@@ -592,7 +600,6 @@ class Empty(IStrategy):
self.pairs[pair]['last_min'] = min(last_candle['close'], self.pairs[pair]['last_min'])
self.pairs[pair]['last_date'] = current_time
dispo = round(self.wallets.get_available_stake_amount())
# self.printLineLog()
stake_amount = self.adjust_stake_amount(pair, last_candle)
@@ -612,7 +619,19 @@ class Empty(IStrategy):
buys=1,
stake=round(stake_amount, 2)
)
else:
self.log_trade(
last_candle=last_candle,
date=current_time,
action=("🟩Buy" if allow_to_buy else "Canceled") + " " + reason,
pair=pair,
rate=rate,
dispo=dispo,
profit=0,
trade_type=entry_tag,
buys=1,
stake=0
)
return allow_to_buy
def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float, rate: float,
@@ -710,12 +729,12 @@ class Empty(IStrategy):
cross = qtpylib.crossed_below(dataframe[self.sell_sma_indicators.value], dataframe[self.sell_crossed_sma_indicators.value])
if profit > 0 and cross.iloc[-1]:
self.pairs[pair]['force_sell'] = True
return 'Cross'
# if profit > 0 and cross.iloc[-1]:
# self.pairs[pair]['force_sell'] = True
# return 'Cross'
if profit > max(5, expected_profit) and baisse > 0.30 and last_candle[f"close"] <= last_candle['sma5']\
and last_candle['percent3'] < 0 and last_candle['percent5'] < 0:
if profit > max(5, expected_profit) and baisse > 0.30 and last_candle[f"close"] <= last_candle['sma36']:
# and last_candle['percent3'] < 0 and last_candle['percent5'] < 0:
self.pairs[pair]['force_sell'] = True
return 'B30'
@@ -832,7 +851,9 @@ class Empty(IStrategy):
informative[f"sma{timeperiod}"] = informative['mid'].ewm(span=timeperiod, adjust=False).mean()
self.calculeDerivees(informative, f"sma{timeperiod}", timeframe=self.timeframe, ema_period=timeperiod)
informative[f"sma200"] = informative['mid'].ewm(span=200, adjust=False).mean()
informative['rsi'] = talib.RSI(informative['close'], timeperiod=14)
self.calculeDerivees(informative, f"rsi", timeframe=self.timeframe, ema_period=14)
informative['max_rsi_12'] = talib.MAX(informative['rsi'], timeperiod=12)
informative['max_rsi_24'] = talib.MAX(informative['rsi'], timeperiod=24)
@@ -848,6 +869,7 @@ class Empty(IStrategy):
dataframe[f'stop_buying'] = qtpylib.crossed_below(dataframe[f"sma12"], dataframe['sma48'])
dataframe['atr'] = talib.ATR(dataframe)
dataframe['rsi'] = talib.RSI(dataframe['close'], timeperiod=14)
dataframe['max_rsi_12'] = talib.MAX(dataframe['rsi'], timeperiod=12)
dataframe['max_rsi_24'] = talib.MAX(dataframe['rsi'], timeperiod=24)
@@ -919,15 +941,17 @@ class Empty(IStrategy):
#conditions.append((dataframe[self.stop_buying_indicator.value] == False) | (dataframe['range_pos'] < 0))
conditions.append(dataframe['sma60_deriv1'] > self.buy_deriv1_sma60.value)
conditions.append(dataframe['sma12_deriv1'] > self.buy_deriv1_sma60.value)
conditions.append(dataframe['sma5_deriv1_1d'] > self.buy_deriv1_sma5d.value)
conditions.append(dataframe['sma12_deriv1_1d'] > self.buy_deriv1_sma12d.value)
conditions.append(dataframe['sma60_deriv2'] > self.buy_deriv1_sma60.value)
conditions.append(dataframe['sma5_deriv2_1d'] > self.buy_deriv1_sma5d.value)
conditions.append(dataframe['sma12_deriv2_1d'] > self.buy_deriv1_sma12d.value)
conditions.append(dataframe['sma12_deriv2'] > self.buy_deriv2_sma60.value)
conditions.append(dataframe['sma5_deriv2_1d'] > self.buy_deriv2_sma5d.value)
conditions.append(dataframe['sma12_deriv2_1d'] > self.buy_deriv2_sma12d.value)
conditions.append(dataframe['hapercent'] > 0)
# conditions.append(dataframe['percent12'] < 0.01)
# conditions.append(dataframe['percent5'] < 0.01)
conditions.append(dataframe['max_rsi_24'] < 80)
conditions.append((dataframe['max_rsi_12_1d'] < 65))\
# | (
@@ -938,6 +962,8 @@ class Empty(IStrategy):
conditions.append(dataframe[f"close"] > dataframe['sma60'])
conditions.append(((dataframe[f"range_pos"] < 0.05) ) | ((dataframe['sma12_deriv1'] > 0) & (dataframe['sma12_deriv2'] > 0)))
conditions.append(dataframe['close_1d'] > dataframe['sma200_1d'])
# print(f"BUY indicators tested \n"
# f"{self.buy_indicator0.value} {self.buy_crossed_indicator0.value} {self.buy_operator0.value} {self.buy_real_num0.value} \n"
# f"{self.buy_indicator1.value} {self.buy_crossed_indicator1.value} {self.buy_operator1.value} {self.buy_real_num1.value} \n"
@@ -1031,17 +1057,17 @@ class Empty(IStrategy):
series = dataframe[f"{name}{suffixe}"]
d1 = series.diff()
d2 = d1.diff()
cond_bas = (d1.rolling(3).mean() > d1.rolling(10).mean())
cond_haut = (d1.rolling(3).mean() < d1.rolling(10).mean())
pmin = int(ema_period / 3)
cond_bas = (d1.rolling(pmin).mean() > d1.rolling(ema_period).mean())
cond_haut = (d1.rolling(pmin).mean() < d1.rolling(ema_period).mean())
dataframe[d1_col] = (dataframe[name] - dataframe[name].shift(3)) / dataframe[name].shift(3)
dataframe[d2_col] = (dataframe[d1_col] - dataframe[d1_col].shift(1))
dataframe[f"{name}{suffixe}_inv"] = np.where(cond_bas, -1, np.where(cond_haut, 1, 0))
short = d1.rolling(3).mean()
long = d1.rolling(10).mean()
short = d1.rolling(pmin).mean()
long = d1.rolling(ema_period).mean()
spread = short - long
zscore = (spread - spread.rolling(ema_period).mean()) / spread.rolling(ema_period).std()
@@ -1131,13 +1157,13 @@ class Empty(IStrategy):
f"{'rsi':>6}|"
)
self.printLineLog()
df = pd.DataFrame.from_dict(self.pairs, orient='index')
colonnes_a_exclure = ['last_candle',
'trade_info', 'last_date', 'last_count_of_buys', 'base_stake_amount', 'stop_buy']
df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure)
# df_filtered = df_filtered["first_buy", "last_max", "max_touch", "last_sell","last_buy", 'count_of_buys', 'current_profit']
print(df_filtered)
# df = pd.DataFrame.from_dict(self.pairs, orient='index')
# colonnes_a_exclure = ['last_candle',
# 'trade_info', 'last_date', 'last_count_of_buys', 'base_stake_amount', 'stop_buy']
# df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure)
# # df_filtered = df_filtered["first_buy", "last_max", "max_touch", "last_sell","last_buy", 'count_of_buys', 'current_profit']
#
# print(df_filtered)
self.columns_logged += 1
date = str(date)[:16] if date else "-"