diff --git a/run.py b/run.py index 5e153a7..4d6d293 100644 --- a/run.py +++ b/run.py @@ -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 ~ max,distinct 天数——回填范围据此定):") + 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}")