diff --git a/.gitignore b/.gitignore index 0d9d47a..8ee6077 100644 --- a/.gitignore +++ b/.gitignore @@ -181,4 +181,4 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ \ No newline at end of file +#.idea/ diff --git a/stock_analyzer.py b/stock_analyzer.py index 39adb56..269872d 100644 --- a/stock_analyzer.py +++ b/stock_analyzer.py @@ -537,6 +537,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, @@ -545,7 +550,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 45ebb39..c771ee2 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 @@