stable1 6

This commit is contained in:
zhangkun9038@dingtalk.com 2025-04-28 17:58:03 +08:00
parent bb7a4af33a
commit e10821a4fc

View File

@ -295,19 +295,19 @@ class FreqaiExampleStrategy(IStrategy):
return dataframe return dataframe
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame: def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# 改进卖出信号条件 # 改进卖出信号条件
exit_long_conditions = [ exit_long_conditions = [
(df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值 (dataframe["rsi"] > dataframe["sell_rsi_pred"]), # RSI 高于卖出阈值
(df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值 (dataframe["volume"] > dataframe["volume"].rolling(window=10).mean()), # 成交量高于近期均值
(df["close"] < df["bb_middleband"]) # 价格低于布林带中轨 (dataframe["close"] < dataframe["bb_middleband"]) # 价格低于布林带中轨
] ]
if exit_long_conditions: if exit_long_conditions:
df.loc[ dataframe.loc[
reduce(lambda x, y: x & y, exit_long_conditions), reduce(lambda x, y: x & y, exit_long_conditions),
"exit_long" "exit_long"
] = 1 ] = 1
return df return dataframe
def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame: def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进买入信号条件 # 改进买入信号条件
# 检查 MACD 列是否存在 # 检查 MACD 列是否存在