From 0e787f54e659463172fe07dcac0b60e3acb9f117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Delacotte?= Date: Sat, 29 Nov 2025 11:59:53 +0100 Subject: [PATCH] rs_trend_probability --- Frictrade.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Frictrade.py b/Frictrade.py index d74ccfd..e1c9111 100644 --- a/Frictrade.py +++ b/Frictrade.py @@ -45,10 +45,7 @@ class Frictrade(IStrategy): # ROI table: minimal_roi = { - "0": 0.564, - "567": 0.273, - "2814": 0.12, - "7675": 0 + "0": 10 } # Stoploss: @@ -424,7 +421,7 @@ class Frictrade(IStrategy): dataframe['max180'] = talib.MAX(dataframe['mid'], timeperiod=180) dataframe['pct180'] = ((dataframe["mid"] - dataframe['min180'] ) / (dataframe['max180'] - dataframe['min180'] )) - dataframe = self.rsi_trend_probability(dataframe) + dataframe = self.rsi_trend_probability(dataframe, short=60, long=360) # ################### INFORMATIVE 1h informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe='1h') @@ -557,6 +554,13 @@ class Frictrade(IStrategy): ath_dist = 100 * (ath - last_candle["mid"]) / ath + # ath_dist + # 0 ==> 1 + # 20 ==> 1.5 + # 40 ==> 2 + # 50 * (1 + (ath_dist / 40)) + base_stake = self.config.get('stake_amount') * (1 + (ath_dist / 40)) + # Calcule max/min 180 low180 = last_candle["min180"] high180 = last_candle["max180"] @@ -565,7 +569,7 @@ class Frictrade(IStrategy): print(f"low={low180} mid={last_candle['mid']} high={high180} mult={mult} ath={ath} ath_dist={round(ath_dist, 2)}" ) # base_size = montant de base que tu veux utiliser (ex: stake_amount ou autre) - base_size = 2 * self.config.get('stake_amount') # exemple fraction du portefeuille; adapte selon ton code + base_size = base_stake # exemple fraction du portefeuille; adapte selon ton code # new stake proportionnel à mult new_stake = base_size * mult return new_stake @@ -805,7 +809,7 @@ class Frictrade(IStrategy): stake=0 ) - if last_candle['sma24_deriv1'] > 0 and minutes < 180: # and last_candle['sma5_deriv1'] > -0.15: + if last_candle['sma24_deriv1'] > 0 and minutes < 180 and baisse < 30: # and last_candle['sma5_deriv1'] > -0.15: return None # ----- 4) OFFSET : faut-il attendre de dépasser trailing_stop_positive_offset ? ----- @@ -817,7 +821,7 @@ class Frictrade(IStrategy): # Sinon : trailing actif dès le début # ----- 6) Condition de vente ----- - if profit > 0 and profit <= trailing_stop and last_candle['mid'] < last_candle['sma5']: + if 0 < profit <= trailing_stop and last_candle['mid'] < last_candle['sma5']: return f"stop_{count_of_buys}_{self.pairs[pair]['has_gain']}" return None @@ -894,16 +898,16 @@ class Frictrade(IStrategy): # return df - def rsi_trend_probability(self, dataframe): + def rsi_trend_probability(self, dataframe, short=6, long=12): dataframe = dataframe.copy() - dataframe['rsi14'] = talib.RSI(dataframe['mid'], 14) - dataframe['rsi60'] = talib.RSI(dataframe['mid'], 60) + dataframe['rsi_short'] = talib.RSI(dataframe['mid'], short) + dataframe['rsi_long'] = talib.RSI(dataframe['mid'], long) - dataframe['cross_soft'] = np.tanh((dataframe['rsi14'] - dataframe['rsi60']) / 7) + dataframe['cross_soft'] = np.tanh((dataframe['rsi_short'] - dataframe['rsi_long']) / 7) - dataframe['gap'] = (dataframe['rsi14'] - dataframe['rsi60']) / 100 - dataframe['trend'] = (dataframe['rsi60'] - 50) / 50 + dataframe['gap'] = (dataframe['rsi_short'] - dataframe['rsi_long']) / 100 + dataframe['trend'] = (dataframe['rsi_long'] - 50) / 50 dataframe['rtp'] = ( 0.6 * dataframe['cross_soft'] +