diff --git a/Zeus_8_3_2_B_4_2.py b/Zeus_8_3_2_B_4_2.py index c791678..2d55da1 100644 --- a/Zeus_8_3_2_B_4_2.py +++ b/Zeus_8_3_2_B_4_2.py @@ -76,15 +76,6 @@ class Zeus_8_3_2_B_4_2(IStrategy): "sma20": { "color": "yellow" }, - "sma20_smooth": { - "color": "green" - }, - "sma20_smooth_2": { - "color": "red", - }, - "sma20_smooth_3": { - "color": "blue", - }, "bb_lowerband": { "color": "#da59a6"}, "bb_upperband": { @@ -218,14 +209,6 @@ class Zeus_8_3_2_B_4_2(IStrategy): protection_fibo = IntParameter(1, 10, default=2, space='protection') sell_allow_decrease = DecimalParameter(0.005, 0.02, default=0.2, decimals=2, space='sell', optimize=True, load=True) - def min_max_scaling(self, series: pd.Series) -> pd.Series: - """Normaliser les données en les ramenant entre 0 et 100.""" - return 100 * (series - series.min()) / (series.max() - series.min()) - - def z_score_scaling(self, series: pd.Series) -> pd.Series: - """Normaliser les données en utilisant Z-Score Scaling.""" - return (series - series.mean()) / series.std() - def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, current_time: datetime, entry_tag: Optional[str], **kwargs) -> bool: @@ -515,9 +498,6 @@ class Zeus_8_3_2_B_4_2(IStrategy): dataframe['sma10_diff'] = 100 * dataframe['sma10'].diff() / dataframe['sma10'] dataframe['sma20'] = talib.SMA(dataframe, timeperiod=20) dataframe['sma20_pct'] = 100 * dataframe['sma20'].diff() / dataframe['sma20'] - dataframe['sma20_smooth'] = dataframe['sma20'].ewm(span=5).mean() - dataframe['sma20_smooth_2'] = dataframe['sma20'].rolling(window=5, center=True).median() - dataframe['sma20_smooth_3'] = self.smooth_series(dataframe['sma20'], alpha_low=0.05, alpha_high=0.3, threshold=0.2) dataframe["percent"] = (dataframe["close"] - dataframe["open"]) / dataframe["open"] dataframe["percent3"] = (dataframe["close"] - dataframe["open"].shift(3)) / dataframe["open"].shift(3) @@ -562,8 +542,6 @@ class Zeus_8_3_2_B_4_2(IStrategy): # dataframe = self.apply_regression_derivatives(dataframe, column='mid', window=24, degree=3) - # Normaliser les données de 'close' - # normalized_close = self.min_max_scaling(dataframe['close']) ################### INFORMATIVE 1h informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe="1h") heikinashi = qtpylib.heikinashi(informative) @@ -670,13 +648,13 @@ class Zeus_8_3_2_B_4_2(IStrategy): def calculateTendency(self, dataframe, window=12): dataframe['mid'] = dataframe['open'] + (dataframe['close'] - dataframe['open']) / 2 - # 2. Calcul du lissage sur 200 bougies par moyenne mobile médiane + # 2. Calcul du lissage par moyenne mobile médiane dataframe['mid_smooth'] = dataframe['close'].rolling(window=window, center=True, min_periods=1).median().rolling( 3).mean() # 2. Dérivée première = différence entre deux bougies successives dataframe['mid_smooth_deriv1'] = round(100 * dataframe['mid_smooth'].diff() / dataframe['mid_smooth'], 4) # 3. Dérivée seconde = différence de la dérivée première - dataframe['mid_smooth_deriv2'] = round(100 * dataframe['mid_smooth_deriv1'].diff().rolling(3).mean(), 4) + dataframe['mid_smooth_deriv2'] = round(10 * dataframe['mid_smooth_deriv1'].diff(), 4) dataframe = self.add_tendency_column(dataframe) return dataframe @@ -721,6 +699,7 @@ class Zeus_8_3_2_B_4_2(IStrategy): # (dataframe["bb_width"] > 0.01) (dataframe['down_count'].shift(1) < - 1) & (dataframe['down_count'] == 0) + # & (dataframe['mid_smooth_deriv1'] <= 0.01) & (dataframe['mid_smooth_deriv1'] >= -0.01) # & (dataframe['tendency'] != "B--") # & (dataframe['tendency'] != "B-") @@ -742,6 +721,11 @@ class Zeus_8_3_2_B_4_2(IStrategy): return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + # dataframe.loc[ + # ( + # (dataframe['mid_smooth_deriv1'] == 0) + # & (dataframe['mid_smooth_deriv1'].shift(1) > 0) + # ), ['sell', 'exit_long']] = (1, 'sell_sma5_pct_1h') return dataframe def adjust_trade_position(self, trade: Trade, current_time: datetime, @@ -870,25 +854,6 @@ class Zeus_8_3_2_B_4_2(IStrategy): # f"Expected profit price={current_price:.4f} min_max={min_max:.4f} min_14={min_14_days:.4f} max_14={max_14_days:.4f} percent={percent:.4f} expected_profit={expected_profit:.4f}") return expected_profit - def smooth_series(self, series, alpha_low=0.1, alpha_high=0.5, threshold=0.2): - """ - Applique un lissage adaptatif sur une série Pandas. - - alpha_low : lissage fort (forte inertie, pour petites variations) - - alpha_high : lissage faible (rapide réaction, pour grandes variations) - - threshold : variation (%) à partir de laquelle on considère le mouvement significatif - """ - smoothed = [series.iloc[0]] - for i in range(1, len(series)): - prev = smoothed[-1] - current = series.iloc[i] - variation = abs(current - prev) / prev * 100 if prev != 0 else 0 - - alpha = alpha_high if variation > threshold else alpha_low - new_val = prev + alpha * (current - prev) - smoothed.append(new_val) - - return pd.Series(smoothed, index=series.index) - def calculateUpDownPct(self, dataframe, key): down_pct_values = np.full(len(dataframe), np.nan) # Remplir la colonne avec les bons calculs @@ -974,3 +939,47 @@ class Zeus_8_3_2_B_4_2(IStrategy): return df + # @property + # def protections(self): + # return [ + # { + # "method": "CooldownPeriod", + # "stop_duration_candles": 12 + # } + # # { + # # "method": "MaxDrawdown", + # # "lookback_period_candles": self.lookback.value, + # # "trade_limit": self.trade_limit.value, + # # "stop_duration_candles": self.protection_stop.value, + # # "max_allowed_drawdown": self.protection_max_allowed_dd.value, + # # "only_per_pair": False + # # }, + # # { + # # "method": "StoplossGuard", + # # "lookback_period_candles": 24, + # # "trade_limit": 4, + # # "stop_duration_candles": self.protection_stoploss_stop.value, + # # "only_per_pair": False + # # }, + # # { + # # "method": "StoplossGuard", + # # "lookback_period_candles": 24, + # # "trade_limit": 4, + # # "stop_duration_candles": 2, + # # "only_per_pair": False + # # }, + # # { + # # "method": "LowProfitPairs", + # # "lookback_period_candles": 6, + # # "trade_limit": 2, + # # "stop_duration_candles": 60, + # # "required_profit": 0.02 + # # }, + # # { + # # "method": "LowProfitPairs", + # # "lookback_period_candles": 24, + # # "trade_limit": 4, + # # "stop_duration_candles": 2, + # # "required_profit": 0.01 + # # } + # ] \ No newline at end of file