历史深度数据探查

This commit is contained in:
zlt 2026-07-24 15:20:29 +08:00
parent 0bbd19f14d
commit 42659b92e9
1 changed files with 10 additions and 8 deletions

18
run.py
View File

@ -40,17 +40,19 @@ def cmd_views():
print(f"{name}: {e!r}")
fronts = [
("热度 heat(trade_date)", "heat", "SELECT MAX(trade_date) FROM stock_fund_heat_scores"),
("一致预期 consensus(asof)", "pg", "SELECT MAX(asof_date) FROM v_factor_consensus"),
("事件 events(disclosure)", "pg", "SELECT MAX(disclosure_date) FROM v_factor_events"),
("传导 transmission(scan)", "pg", "SELECT MAX(scan_date) FROM v_factor_transmission"),
("行情 gp_day_data(ts)", "price", "SELECT MAX(`timestamp`) FROM gp_day_data"),
("热度 heat", "heat", "trade_date", "stock_fund_heat_scores"),
("一致预期 consensus", "pg", "asof_date", "v_factor_consensus"),
("事件 events", "pg", "disclosure_date", "v_factor_events"),
("传导 transmission", "pg", "scan_date", "v_factor_transmission"),
("行情 gp_day_data", "price", "`timestamp`", "gp_day_data"),
]
print("\n数据前沿各源最新日期——build 的 --date 照此选,别选没数据的未来日):")
for name, src, sql in fronts:
print("\n数据历史深度min ~ maxdistinct 天数——回填范围据此定):")
for name, src, col, tbl in fronts:
sql = f"SELECT MIN({col}), MAX({col}), COUNT(DISTINCT {col}) FROM {tbl}"
try:
df = db.read_pg(sql) if src == "pg" else db.read_mysql(src, sql)
print(f" {name}: {df.iloc[0, 0]}")
lo, hi, n = df.iloc[0, 0], df.iloc[0, 1], df.iloc[0, 2]
print(f" {name}: {lo} ~ {hi} ({int(n)} 天)")
except Exception as e: # noqa: BLE001
print(f" {name}: ❌ {e!r}")