147 lines
6.3 KiB
Python
147 lines
6.3 KiB
Python
"""被监控对象注册表 — spec §20.15.1 权威导出(2026-09-25 初值, 行数带宽跑两周后校准).
|
|
|
|
kind 语义(监控检查分发依据, 见 monitor_checks/data_monitor):
|
|
per_date static/<name>/YYYYMMDD_<name>.parquet 日频/快照: 新鲜度(红)+行数带宽(黄)
|
|
weekly_friday 周五锚 YYYYMMDD_<name>.parquet: 周六 ready 后新鲜度(红)
|
|
month_bucket YYYYMM_<name>.parquet: 最新桶距今<=max_age_days(黄)+带宽(黄)
|
|
year_file data/valuation_baostock/<YYYY>.parquet 当年文件 mtime>=期望日
|
|
dir_mtime 目录内最新 mtime 距今<=max_age_days(黄)
|
|
db_sample quant_trading.db 抽样 MAX(datetime)>=期望交易日(红)
|
|
vintage_json 读 data/static/vintage_status.json 结论字段
|
|
log_only 仅过程层: 统计行存在且 failed=0(ak 逐股族)
|
|
static_exists one-shot 文件存在性
|
|
disk 数据根剩余空间
|
|
"""
|
|
import re
|
|
|
|
|
|
def _pd(name, band, ready="20:30", lag=0, severity="red", producer="vps"):
|
|
return {"name": name, "kind": "per_date", "root": "static", "subdir": name,
|
|
"pattern": rf"^(\d{{8}})_{re.escape(name)}$", "row_band": band,
|
|
"ready": ready, "lag": lag, "severity": severity,
|
|
"producer": producer, "enabled": True}
|
|
|
|
|
|
_PER_DATE = [
|
|
_pd("dragon_tiger", (0, 400)),
|
|
_pd("block_trade", (30, 300)),
|
|
_pd("restricted", (0, 60)),
|
|
_pd("zt_pool", (15, 150)),
|
|
_pd("zt_pool_zbgc", (1, 60)),
|
|
_pd("zt_pool_dtgc", (1, 60)),
|
|
_pd("fund_flow_industry", (60, 120)),
|
|
_pd("fund_flow_concept", (200, 600)),
|
|
_pd("ths_industry", (60, 120)),
|
|
_pd("ths_concept", (200, 600)),
|
|
_pd("sina_sector", (30, 80)),
|
|
_pd("sw_industry", (4500, 6000)), # 申万成分股粒度(09-26 实测 5220, spec 的 31=行业数)
|
|
_pd("xueqiu_hot", (5000, 6500)),
|
|
_pd("hot_rank", (99, 101), ready="18:30", producer="nas"),
|
|
_pd("margin", (200, 4000), ready="21:00", lag=1),
|
|
_pd("margin_sse", (200, 4000), ready="21:00", lag=1),
|
|
_pd("dragon_tiger_seats", (0, 400)),
|
|
_pd("nb_daily", (30, 150)),
|
|
]
|
|
|
|
_WEEKLY = [
|
|
{"name": "pledge_ratio", "kind": "weekly_friday", "root": "static",
|
|
"subdir": "pledge_ratio", "pattern": r"^(\d{8})_pledge_ratio$",
|
|
"row_band": (1500, 3000), "ready": "06:00", "severity": "red",
|
|
"producer": "vps", "enabled": True},
|
|
{"name": "research_report", "kind": "weekly_friday", "root": "static",
|
|
"subdir": "research_report", "pattern": r"^(\d{8})_research_report$",
|
|
"row_band": (50, 1500), "ready": "06:00", "severity": "red",
|
|
"producer": "vps", "enabled": True},
|
|
]
|
|
|
|
_MONTH = [
|
|
{"name": "pledge_detail", "kind": "month_bucket", "root": "static",
|
|
"subdir": "pledge_detail", "pattern": r"^(\d{6})_pledge_detail$",
|
|
"row_band": (40000, 250000), "max_age_days": 45, "severity": "yellow",
|
|
"producer": "vps", "enabled": True},
|
|
]
|
|
|
|
_YEAR = [
|
|
{"name": "valuation_baostock", "kind": "year_file", "root": "data",
|
|
"subdir": "valuation_baostock", "ready": "22:30", "severity": "yellow",
|
|
"producer": "vps", "enabled": True},
|
|
]
|
|
|
|
_DIR_MTIME = [
|
|
# (name, root, subdir, max_age_days, cadence 注释)
|
|
("gdhs", "static", "gdhs", 10), # ak-weekly 增量
|
|
("share_capital", "static", "share_capital", 10),
|
|
("top_holders", "static", "top_holders", 45),
|
|
("financial_abstract", "static", "financial_abstract", 45),
|
|
("nb_hold", "static", "nb_hold", 120), # 季频快照
|
|
("balance", "static", "balance", 130), # 三表 marathon 季频
|
|
("income", "static", "income", 130),
|
|
("cashflow", "static", "cashflow", 130),
|
|
("forecast", "static", "forecast", 130),
|
|
("express", "static", "express", 130),
|
|
("fundamentals_baostock", "data", "fundamentals_baostock", 4),
|
|
("index_const_hist", "data", "index_const_hist", 40), # idx-monthly 16日
|
|
]
|
|
|
|
_DB_SAMPLE = [
|
|
{"name": "dbbardata_daily", "kind": "db_sample", "root": "data",
|
|
"samples": [["600519", "SSE"], ["000001", "SZSE"], ["510300", "SSE"],
|
|
["159915", "SZSE"]],
|
|
"ready": "22:30", "lag": 0, "severity": "red", "producer": "vps",
|
|
"enabled": True}, # bs-daily 马拉松+xt 腿混合写入
|
|
{"name": "dbbardata_index", "kind": "db_sample", "root": "data",
|
|
"samples": [["000300", "SSE"], ["000905", "SSE"]],
|
|
"ready": "19:00", "lag": 0, "severity": "red", "producer": "vps",
|
|
"enabled": True}, # idx 18:30 9 指数
|
|
]
|
|
|
|
_MISC = [
|
|
{"name": "valuation", "kind": "log_only", "log_cadence": "daily",
|
|
"enabled": True, "producer": "vps", "severity": "red"},
|
|
{"name": "northbound", "kind": "log_only", "log_cadence": "weekly",
|
|
"enabled": False, "producer": "vps", "severity": "yellow",
|
|
"note": "§20.4 backlog 域(2024-08 停发), 只登记防漏, 不检查"},
|
|
{"name": "index_const", "kind": "static_exists", "root": "static",
|
|
"subdir": "index_const", "enabled": True, "producer": "vps",
|
|
"severity": "yellow"},
|
|
{"name": "industry", "kind": "static_exists", "root": "static",
|
|
"subdir": "industry", "enabled": True, "producer": "vps",
|
|
"severity": "yellow"},
|
|
{"name": "vintage", "kind": "vintage_json", "root": "static",
|
|
"subdir": "vintage_status.json", "enabled": True, "producer": "vps",
|
|
"severity": "yellow"},
|
|
{"name": "disk", "kind": "disk", "warn_gb": 20, "crit_gb": 8,
|
|
"enabled": True, "producer": "vps", "severity": "red"},
|
|
]
|
|
|
|
|
|
def _dir_entries():
|
|
out = []
|
|
for name, root, subdir, days in _DIR_MTIME:
|
|
out.append({"name": name, "kind": "dir_mtime", "root": root,
|
|
"subdir": subdir, "max_age_days": days,
|
|
"severity": "yellow", "producer": "vps", "enabled": True})
|
|
return out
|
|
|
|
|
|
REGISTRY = (_PER_DATE + _WEEKLY + _MONTH + _YEAR + _dir_entries()
|
|
+ _DB_SAMPLE + _MISC)
|
|
|
|
# 调度层在岗检查(spec §20.15.1 表后注: 14 个 schtask; retry 一次性死案即此类)
|
|
SCHTASKS = [
|
|
("sanguo-qmt-relogin", "daily"),
|
|
("sanguo-qmt-sentinel", "always"),
|
|
("sanguo-qmt-probe0915", "weekday"),
|
|
("sanguo-live-supervisor", "always"),
|
|
("sanguo-shadow-desk", "always"),
|
|
("sanguo-api", "always"),
|
|
("sanguo-bs-daily", "daily"),
|
|
("sanguo-xt-daily", "daily"),
|
|
("sanguo-ak-daily", "daily"),
|
|
("sanguo-ak-events", "daily"),
|
|
("sanguo-ak-events-retry", "weekday"),
|
|
("sanguo-ak-weekly", "weekly"),
|
|
("sanguo-ak-vintage", "daily"),
|
|
("sanguo-index", "monthly"),
|
|
]
|