diff --git a/FrictradeLearning.py b/FrictradeLearning.py index 774c42d..d363769 100644 --- a/FrictradeLearning.py +++ b/FrictradeLearning.py @@ -180,7 +180,7 @@ class FrictradeLearning(IStrategy): "note": "pic oct. 2025 (source agrégée, à vérifier selon l'exchange)"} ] - def dynamic_trailing_offset(self, pair, stake, price, ath, count_of_buys, max_dca=5): + def dynamic_trailing_offset(self, pair, stake, last_candle, price, ath, count_of_buys, max_dca=5): # dd_ath = (ath - price) / ath # dd_ath = max(0.0, min(dd_ath, 0.5)) # @@ -192,6 +192,9 @@ class FrictradeLearning(IStrategy): # OFFSET_MIN = self.offset_min.value # OFFSET_MAX = self.offset_min.value + self.offset_max.value + if last_candle['sma180_deriv1'] < 0.005: + return stake / 200 + return stake / 100 # OFFSET_MIN + breathing_score * (OFFSET_MAX - OFFSET_MIN) def cooldown_from_heat(self, score): @@ -468,7 +471,8 @@ class FrictradeLearning(IStrategy): 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'] + 'trade_info', 'last_date', 'last_count_of_buys', + 'base_stake_amount', 'stop_buy', 'mises', 'dca_thresholds'] df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure) # df_filtered = df_filtered["first_price", "last_max", "max_touch", "last_sell","last_price", 'count_of_buys', 'current_profit'] @@ -890,6 +894,12 @@ class FrictradeLearning(IStrategy): self.calculeDerivees(dataframe, 'sma12', ema_period=6) self.calculeDerivees(dataframe, 'sma5', ema_period=3) + dataframe['sma60'] = dataframe['mid'].ewm(span=60, adjust=False).mean() + self.calculeDerivees(dataframe, 'sma60', ema_period=20) + + dataframe['sma180'] = dataframe['mid'].ewm(span=180, adjust=False).mean() + self.calculeDerivees(dataframe, 'sma180', ema_period=60) + horizon = 180 self.calculateScores(dataframe, horizon) @@ -979,7 +989,7 @@ class FrictradeLearning(IStrategy): total_stake += stake pct += dca loss_amount += total_stake * dca_previous - offset = self.dynamic_trailing_offset(pair, total_stake, price=val, ath=ath, count_of_buys=count) + offset = self.dynamic_trailing_offset(pair, total_stake, last_candle, price=val, ath=ath, count_of_buys=count) 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)}") @@ -1059,6 +1069,8 @@ class FrictradeLearning(IStrategy): & (dataframe['sma5_deriv1'] > 0) & (dataframe['sma5_deriv2'] > 0) & (dataframe['rsi'] < 77) + & (dataframe['heat_score_1h'] < 0.5) + & (dataframe['sma180_deriv1'] > 0) # & (dataframe['open'] < dataframe['max180'] * 0.997) # & (dataframe['min180'].shift(3) == dataframe['min180']) , ['enter_long', 'enter_tag'] @@ -1454,7 +1466,7 @@ class FrictradeLearning(IStrategy): current_trailing_only_offset_is_reached = self.trailing_only_offset_is_reached current_trailing_stop_positive_offset = self.trailing_stop_positive_offset - current_trailing_stop_positive_offset = self.dynamic_trailing_offset(pair, self.pairs[pair]['total_amount'], price=current_rate, + current_trailing_stop_positive_offset = self.dynamic_trailing_offset(pair, self.pairs[pair]['total_amount'], last_candle, price=current_rate, ath=self.pairs[pair]['last_ath'], count_of_buys=count_of_buys)