From 82e4ee5b64248ab31a1a1a0af784a45b0291da7e Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Mon, 2 Feb 2026 13:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=9B=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TF_DF.py | 8 ++++---- strategies/ChanLun_EMA52.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TF_DF.py b/TF_DF.py index cc19768..1fc226d 100644 --- a/TF_DF.py +++ b/TF_DF.py @@ -47,17 +47,17 @@ class TF_DF(): self.zs_list = self.get_zs_list(self.bi_list, self.seg_list) self.chanmacd = ChanMACD(self.klu_list) self.klu_list = self.chanmacd.cal_macd_state() - def get_ema52(self): + def get_ema52(self, index=-1): if self.klu_list: - ema52_value = self.klu_list[-1].ema52 + ema52_value = self.klu_list[index].ema52 # 处理NaN值 if pd.isna(ema52_value) or ema52_value is None: return None return float(ema52_value) return None - def get_ema24(self): + def get_ema24(self, index=-1): if self.klu_list: - ema24_value = self.klu_list[-1].ema24 + ema24_value = self.klu_list[index].ema24 # 处理NaN值 if pd.isna(ema24_value) or ema24_value is None: return None diff --git a/strategies/ChanLun_EMA52.py b/strategies/ChanLun_EMA52.py index 40056fd..004cec4 100644 --- a/strategies/ChanLun_EMA52.py +++ b/strategies/ChanLun_EMA52.py @@ -104,12 +104,13 @@ class ChanLun_EMA52(IStrategy): def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) if self.last_time + timedelta(minutes=1) < datetime.now(): + self.last_time = datetime.now() logger.info("init_dataframes----------------------------") last_price = dataframe.iloc[-1]['close'] + date = dataframe.iloc[-1]['date'] tf_ema52_list = self.chan.check_price_ema52(last_price) self.init_dataframes(dataframe) - logger.info("Price_ema52_list: " + str(tf_ema52_list)) - self.last_time = datetime.now() + logger.info("Date: " + date.strftime('%Y-%m-%d %H:%M:%S') + " Price: " + str(last_price) + " EMA52_list: " + str(tf_ema52_list)) return dataframe def init_dataframes(self, dataframe_1m): dataframe_15m = self.dp.get_pair_dataframe(pair=self.pair, timeframe='15m')