rs_trend_probability

This commit is contained in:
Jérôme Delacotte
2025-11-29 11:59:53 +01:00
parent b270b3b283
commit 0e787f54e6

View File

@@ -45,10 +45,7 @@ class Frictrade(IStrategy):
# ROI table: # ROI table:
minimal_roi = { minimal_roi = {
"0": 0.564, "0": 10
"567": 0.273,
"2814": 0.12,
"7675": 0
} }
# Stoploss: # Stoploss:
@@ -424,7 +421,7 @@ class Frictrade(IStrategy):
dataframe['max180'] = talib.MAX(dataframe['mid'], timeperiod=180) dataframe['max180'] = talib.MAX(dataframe['mid'], timeperiod=180)
dataframe['pct180'] = ((dataframe["mid"] - dataframe['min180'] ) / (dataframe['max180'] - dataframe['min180'] )) 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 1h
informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe='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 = 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 # Calcule max/min 180
low180 = last_candle["min180"] low180 = last_candle["min180"]
high180 = last_candle["max180"] 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)}" ) 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 = 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 proportionnel à mult
new_stake = base_size * mult new_stake = base_size * mult
return new_stake return new_stake
@@ -805,7 +809,7 @@ class Frictrade(IStrategy):
stake=0 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 return None
# ----- 4) OFFSET : faut-il attendre de dépasser trailing_stop_positive_offset ? ----- # ----- 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 # Sinon : trailing actif dès le début
# ----- 6) Condition de vente ----- # ----- 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 f"stop_{count_of_buys}_{self.pairs[pair]['has_gain']}"
return None return None
@@ -894,16 +898,16 @@ class Frictrade(IStrategy):
# return df # return df
def rsi_trend_probability(self, dataframe): def rsi_trend_probability(self, dataframe, short=6, long=12):
dataframe = dataframe.copy() dataframe = dataframe.copy()
dataframe['rsi14'] = talib.RSI(dataframe['mid'], 14) dataframe['rsi_short'] = talib.RSI(dataframe['mid'], short)
dataframe['rsi60'] = talib.RSI(dataframe['mid'], 60) 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['gap'] = (dataframe['rsi_short'] - dataframe['rsi_long']) / 100
dataframe['trend'] = (dataframe['rsi60'] - 50) / 50 dataframe['trend'] = (dataframe['rsi_long'] - 50) / 50
dataframe['rtp'] = ( dataframe['rtp'] = (
0.6 * dataframe['cross_soft'] + 0.6 * dataframe['cross_soft'] +