From c26966da459fa74757dc4c7731c766aed810914e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Delacotte?= Date: Sat, 20 Dec 2025 20:31:09 +0100 Subject: [PATCH] FrictradeLearning --- FrictradeLearning.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/FrictradeLearning.py b/FrictradeLearning.py index 63fd7bf..774c42d 100644 --- a/FrictradeLearning.py +++ b/FrictradeLearning.py @@ -73,7 +73,7 @@ RESET = "\033[0m" class FrictradeLearning(IStrategy): - startup_candle_count = 200 + startup_candle_count = 360 train_model = None model_indicators = [] DEFAULT_PARAMS = { @@ -634,6 +634,8 @@ class FrictradeLearning(IStrategy): informative['rsi'] = talib.RSI(informative['mid'], timeperiod=14) self.calculeDerivees(informative, 'rsi', ema_period=12) + self.calculateScores(informative, 6) + # informative = self.rsi_trend_probability(informative) # probas = self.calculModelInformative(informative) @@ -889,13 +891,7 @@ class FrictradeLearning(IStrategy): self.calculeDerivees(dataframe, 'sma5', ema_period=3) horizon = 180 - dataframe['price_change'] = (dataframe['close'] - dataframe['close'].shift(horizon)) / dataframe['close'].shift(horizon) - # dataframe['rsi_delta'] = dataframe['rsi'] - dataframe['rsi'].shift(horizon) - - dataframe['price_score'] = (dataframe['price_change'] / 0.05).clip(0, 2) - # dataframe['rsi_score'] = (dataframe['rsi_delta'] / 15).clip(0, 2) - - dataframe['heat_score'] = talib.MAX(dataframe['price_score'], timeperiod=horizon) #+ dataframe['rsi_score'] + self.calculateScores(dataframe, horizon) # val = 90000 # steps = 12 @@ -957,6 +953,7 @@ class FrictradeLearning(IStrategy): if self.pairs[pair]['count_of_buys']: dca_threshold = self.pairs[pair]['dca_thresholds'][min(self.pairs[pair]['count_of_buys'] - 1, len(self.pairs[pair]['dca_thresholds']) - 1)] + dataframe[f"next_dca"] = val * (1 - dca_threshold) print(f"count_of_buys={self.pairs[pair]['count_of_buys']} dca_threshold={dca_threshold} {self.pairs[pair]['dca_thresholds']}") print(f"val={val} dca={self.pairs[pair]['dca_thresholds']} ath={self.pairs[pair]['last_ath']} first_price={self.pairs[pair]['first_price']}") @@ -984,7 +981,7 @@ class FrictradeLearning(IStrategy): loss_amount += total_stake * dca_previous offset = self.dynamic_trailing_offset(pair, total_stake, price=val, ath=ath, count_of_buys=count) - if count == self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain']: + if count == self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] - 1: print(f"next_buy={round(val * (1 - pct),1)} count={count} pct={round(pct, 4)}") dataframe[f"next_buy"] = val * (1 - pct) count += 1 @@ -996,6 +993,13 @@ class FrictradeLearning(IStrategy): return dataframe + def calculateScores(self, dataframe, horizon): + dataframe['price_change'] = (dataframe['close'] - dataframe['close'].shift(horizon)) / dataframe['close'].shift(horizon) + # dataframe['rsi_delta'] = dataframe['rsi'] - dataframe['rsi'].shift(horizon) + dataframe['price_score'] = (dataframe['price_change'] / 0.05).clip(0, 2) + # dataframe['rsi_score'] = (dataframe['rsi_delta'] / 15).clip(0, 2) + dataframe['heat_score'] = talib.MAX(dataframe['price_score'], timeperiod=horizon) # + dataframe['rsi_score'] + def getOpenTrades(self): # if len(self.trades) == 0: self.trades = Trade.get_open_trades() @@ -1059,7 +1063,7 @@ class FrictradeLearning(IStrategy): # & (dataframe['min180'].shift(3) == dataframe['min180']) , ['enter_long', 'enter_tag'] ] = (1, f"future") - dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.003, np.nan) + dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan) return dataframe @@ -2334,6 +2338,9 @@ class FrictradeLearning(IStrategy): and not c.startswith('sma12_deriv1_1h') and not c.startswith('sma12_1h') and not c.startswith('confidence_index') + and not c.startswith('price_change') + and not c.startswith('price_score') + and not c.startswith('heat_score') ] # Étape 3 : remplacer inf et NaN par 0 dataframe[usable_cols] = dataframe[usable_cols].replace([np.inf, -np.inf], 0).fillna(0)