From 527e31f0f52dce89b5aa258595bd8ac3a04ffa84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=80=9D=E5=8D=97?= <15083356+zhu-sinan@user.noreply.gitee.com> Date: Mon, 9 Mar 2026 16:56:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E4=B8=BA=E4=BA=A4=E6=98=93=E6=97=A5?= =?UTF-8?q?=E7=9A=84=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- industry_heat_task.py | 37 +++++++++++++++++++++++++++---------- mqreceivefromllm.py | 1 - 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/industry_heat_task.py b/industry_heat_task.py index 9b0de75..339df78 100644 --- a/industry_heat_task.py +++ b/industry_heat_task.py @@ -48,8 +48,8 @@ class SWIndustryHeatTracker: } # 初始化数据库表 - if self.db_config: - self._init_database() + # if self.db_config: + # self._init_database() def _init_database(self): """初始化MySQL数据库和表""" @@ -104,6 +104,14 @@ class SWIndustryHeatTracker: return set(dates) + def is_trading_day(self, date=None): + """判断是否为交易日""" + if date is None: + date = datetime.now() + if isinstance(date, datetime): + date = date.strftime('%Y-%m-%d') + return date in self.trading_dates + def _update_calendar_cache(self, cache_file): """更新交易日历缓存""" print("正在更新交易日历...") @@ -352,6 +360,18 @@ class SWIndustryHeatTracker: f"量比:{row['volume_ratio']:4.2f} | " f"动量:{row['momentum']:.0%}") + # 打印冷门板块(后10名) + print(f"\n❄️ 冷门板块 (后10名):") + print("-"*80) + bottom10 = heat_df.tail(10) + for _, row in bottom10.iterrows(): + print(f"{row['rank']:2d}. {row['name']:8s} | " + f"热度:{row['heat_score']:5.1f}({row['heat_level']}) | " + f"收益:{row['total_return']:+6.2f}% | " + f"换手:{row['avg_turnover']:5.2f}% | " + f"量比:{row['volume_ratio']:4.2f} | " + f"动量:{row['momentum']:.0%}") + # 保存数据部分 if save: today = datetime.now().strftime('%Y-%m-%d') @@ -378,14 +398,6 @@ class SWIndustryHeatTracker: # 使用示例 if __name__ == "__main__": # 数据库配置 - # config = { - # 'host': 'localhost', - # 'port': 3306, - # 'user': 'your_username', - # 'password': 'your_password', - # 'database': 'your_database', - # 'charset': 'utf8mb4' - # } config = { 'host': '10.127.2.207', 'user': 'financial_prod', @@ -401,5 +413,10 @@ if __name__ == "__main__": db_config=config # 传入数据库配置 ) + check_date = datetime.now().strftime('%Y-%m-%d') + if not tracker.is_trading_day(check_date): + print(f"\n⚠️ {check_date} 不是交易日,跳过计算\n\n") + exit(0) + # 生成报告并自动存入MySQL result = tracker.generate_report(save=True, to_mysql=True) \ No newline at end of file diff --git a/mqreceivefromllm.py b/mqreceivefromllm.py index 4972cff..41286d6 100644 --- a/mqreceivefromllm.py +++ b/mqreceivefromllm.py @@ -24,7 +24,6 @@ def message_callback(ch, method, properties, body): # 数据写入资讯精选表 write_to_news(data) - # 手动确认消息 ch.basic_ack(delivery_tag=method.delivery_tag) except Exception as e: