From 2a946731d7afa252d3074d653f75d6e1620bb81d Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sat, 30 Aug 2025 11:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E6=96=B0=E7=9A=84=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 44 ----------------------------- 1 file changed, 44 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 7ed4e3b9..db8743a2 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -61,48 +61,4 @@ class FreqaiPrimer(IStrategy): (dataframe['close'].shift(1) < dataframe['open'].shift(1)) & # 前一根是阴线 (dataframe['close'] > dataframe['open']) & # 当前是阳线 (dataframe['close'] > dataframe['open'].shift(1)) & # 吞没前一根 - (dataframe['open'] < dataframe['close'].shift(1)) - ) - return dataframe - - def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - # 做多条件 - dataframe.loc[ - ( - # 3m 周期:价格触碰下轨且 RSI 超卖 - (dataframe['close'] <= dataframe['bb_lower_3m']) & - (dataframe['rsi_3m'] < self.rsi_oversold) & - # 15m 周期:RSI 超卖 - (dataframe['rsi_15m'] < self.rsi_oversold) & - # 1h 周期:价格在下轨附近 - (dataframe['close'] <= dataframe['bb_lower_1h']) & - # K线形态确认 - (dataframe['bullish_engulfing']) & - # 成交量过滤:成交量高于 20 周期均量 - (dataframe['volume'] > dataframe['volume_ma']) - ), - 'enter_long'] = 1 - - return dataframe - - def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - # 做多退出:价格触碰布林带上轨或 RSI 超买 - dataframe.loc[ - ( - (dataframe['close'] >= dataframe['bb_upper_3m']) | - (dataframe['rsi_3m'] > self.rsi_overbought) - ), - 'exit_long'] = 1 - - return dataframe - - def custom_stoploss(self, pair: str, trade: 'Trade', current_time, current_rate: float, - current_profit: float, **kwargs) -> float: - # 动态止损基于 ATR - dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) - last_candle = dataframe.iloc[-1] - atr = last_candle['atr'] - if atr > 0: - return -1.5 * atr / current_rate # 动态止损为 1.5 倍 ATR - return self.stoploss # 回退到固定止损 \ No newline at end of file