From af6ff20f8cf0336688d27065815befcc8e808e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B0=E5=BF=97=E5=AE=8F?= Date: Wed, 5 Mar 2025 09:34:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20rsi=20NaN=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stock_analyzer.py | 7 ++++++- templates/index.html | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stock_analyzer.py b/stock_analyzer.py index bcf9375..4ba30f4 100644 --- a/stock_analyzer.py +++ b/stock_analyzer.py @@ -478,6 +478,11 @@ class StockAnalyzer: latest = df.iloc[-1] prev = df.iloc[-2] + # 处理 RSI 的 NaN 值 + rsi_value = latest['RSI'] + if pd.isna(rsi_value): + rsi_value = None + # 生成报告(保持原有格式) report = { 'stock_code': stock_code, @@ -486,7 +491,7 @@ class StockAnalyzer: 'price': latest['close'], 'price_change': (latest['close'] - prev['close']) / prev['close'] * 100, 'ma_trend': 'UP' if latest['MA5'] > latest['MA20'] else 'DOWN', - 'rsi': latest['RSI'], + 'rsi': rsi_value, # 使用处理后的 RSI 值 'macd_signal': 'BUY' if latest['MACD'] > latest['Signal'] else 'SELL', 'volume_status': 'HIGH' if latest['Volume_Ratio'] > 1.5 else 'NORMAL', 'recommendation': self.get_recommendation(score) diff --git a/templates/index.html b/templates/index.html index eeeeb61..71f58bd 100644 --- a/templates/index.html +++ b/templates/index.html @@ -772,9 +772,9 @@ 投资建议 ${result.recommendation} -
+
RSI指标 - ${result.rsi.toFixed(2)} + ${result.rsi !== null ? result.rsi.toFixed(2) : '暂无数据'}
From f5ebe297827a8dde702ff3f1cdcef131f851c3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B0=E5=BF=97=E5=AE=8F?= Date: Wed, 5 Mar 2025 10:03:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=B8=82=E5=9C=BA=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++-- templates/index.html | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index addb0a7..399ad79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -*.log -. * \ No newline at end of file +logs/* +.* \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 71f58bd..cd8f536 100644 --- a/templates/index.html +++ b/templates/index.html @@ -62,6 +62,9 @@ // 关闭公告的函数 function closeAnnouncement() { const container = document.getElementById('announcement-container'); + if(!container){ + return; + } container.style.opacity = '0'; container.style.transform = 'translateY(-10px)'; container.style.transition = 'all 0.3s ease-out'; @@ -111,7 +114,7 @@