Files
kis_bot/scratch/check_after_restart.py

47 lines
1.8 KiB
Python

import sys, os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
from database import TradeDB
db = TradeDB()
try:
# 재시작 후 LS WS 틱 수집 상태
print("[LS WS 틱 - 오늘 시간대별]")
ls_hourly = db.conn.execute("""
SELECT HOUR(FROM_UNIXTIME(timestamp/1000)) as hr, count(*) as c
FROM ls_ws_ticks
WHERE DATE(FROM_UNIXTIME(timestamp/1000)) = '2026-08-31'
GROUP BY hr ORDER BY hr
""").fetchall()
for r in ls_hourly:
print(f" {dict(r)}")
# 후보 목록 (target_candidates)
print("\n[target_candidates 현황]")
cands = db.conn.execute("SELECT count(*) as c, market FROM target_candidates GROUP BY market").fetchall()
for r in cands:
print(f" {dict(r)}")
# ls_universe_history 오늘 데이터
print("\n[ls_universe_history 오늘]")
cols = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM ls_universe_history").fetchall()]
print(" cols:", cols)
ts_col = next((c for c in ['created_at','updated_at','scan_time','ts','timestamp'] if c in cols), cols[0] if cols else None)
if ts_col:
cnt = db.conn.execute(f"SELECT count(*) as c FROM ls_universe_history WHERE DATE({ts_col}) = '2026-08-31'").fetchone()
print(f" 오늘 건수: {dict(cnt)}")
# 12:22 이후 ls_ws_ticks 새 데이터
print("\n[12:22 재시작 이후 LS 틱 수]")
new_ticks = db.conn.execute("""
SELECT count(*) as c FROM ls_ws_ticks
WHERE FROM_UNIXTIME(timestamp/1000) >= '2026-08-31 12:22:00'
""").fetchone()
print(f" 재시작 이후 틱: {dict(new_ticks)}")
latest = db.conn.execute("""
SELECT MAX(FROM_UNIXTIME(timestamp/1000)) as last FROM ls_ws_ticks
""").fetchone()
print(f" 가장 최근 틱: {dict(latest)}")
finally:
db.close()