v1.6.0: 目标跟踪(概念/主题/股票) - watch_targets表+概念智能体跟踪(关键词检索+受益个股+影响度判定+邮件通知), 自动化页加持仓管理和目标管理, 报告支持股票/概念双类型

This commit is contained in:
2026-08-19 23:49:37 +08:00
parent b34006c0d8
commit 9406f9de43
7 changed files with 389 additions and 65 deletions
+18 -2
View File
@@ -142,10 +142,11 @@ CREATE TABLE IF NOT EXISTS notification_log (
CREATE TABLE IF NOT EXISTS tracking_reports (
id INTEGER PRIMARY KEY AUTOINCREMENT,
target_type TEXT DEFAULT 'stock', -- stock(股票) / concept(概念主题)
code TEXT NOT NULL,
stock_name TEXT DEFAULT '',
industry TEXT DEFAULT '',
report TEXT DEFAULT '', -- 产业链深度分析(markdown
report TEXT DEFAULT '', -- 产业链/概念深度分析(markdown
meta TEXT DEFAULT '{}', -- JSONsignificance/impact_score/summary/新闻统计
sources TEXT DEFAULT '{}', -- JSON:个股/上游/下游/同业 采集的资讯 + 指标 + 评级
status TEXT DEFAULT 'done',
@@ -153,6 +154,16 @@ CREATE TABLE IF NOT EXISTS tracking_reports (
);
CREATE INDEX IF NOT EXISTS idx_tracking_code ON tracking_reports(code);
CREATE TABLE IF NOT EXISTS watch_targets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT DEFAULT 'concept', -- concept(概念/主题) / stock(股票)
code TEXT DEFAULT '', -- stock 时的股票代码
name TEXT NOT NULL, -- 概念/主题名 或 股票名
keywords TEXT DEFAULT '', -- concept 的检索关键词(逗号分隔)
enabled INTEGER DEFAULT 1,
created_at TEXT DEFAULT (datetime('now','localtime'))
);
CREATE TABLE IF NOT EXISTS market_index (
date TEXT PRIMARY KEY,
sh REAL DEFAULT 0, -- 上证指数(点)
@@ -187,6 +198,10 @@ def db():
def init_db():
with db() as conn:
conn.executescript(SCHEMA)
# 迁移:老库补列
cols = {r[1] for r in conn.execute("PRAGMA table_info(tracking_reports)")}
if "target_type" not in cols:
conn.execute("ALTER TABLE tracking_reports ADD COLUMN target_type TEXT DEFAULT 'stock'")
def query(sql, args=()):
@@ -219,7 +234,8 @@ def wipe_all():
"""清空业务表(保留结构)+ 重置自增序列,用于重灌数据"""
for t in ("stock_daily", "inst_ratings", "fund_holdings", "news",
"institutions", "stocks", "watchlist", "analysis_cache", "analysis_history",
"market_index", "strategy_backtests", "notification_log", "tracking_reports"):
"market_index", "strategy_backtests", "notification_log", "tracking_reports",
"watch_targets"):
with db() as conn:
conn.execute(f'DELETE FROM "{t}"')
with db() as conn: