52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
|
from database import TradeDB
|
|
|
|
db = TradeDB()
|
|
try:
|
|
print("[LS Universe History Cols]")
|
|
cols_lu = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM ls_universe_history").fetchall()]
|
|
print(cols_lu)
|
|
|
|
date_col_lu = 'scan_time' if 'scan_time' in cols_lu else ('created_at' if 'created_at' in cols_lu else 'ts')
|
|
lu_data = db.conn.execute(f"SELECT * FROM ls_universe_history WHERE date({date_col_lu}) = '2026-08-31'").fetchall()
|
|
print(f"LS Universe count for today: {len(lu_data)}")
|
|
if len(lu_data) > 0:
|
|
print("Sample:", dict(lu_data[-1]))
|
|
|
|
print("\n[Target Candidates History Cols]")
|
|
cols_tc = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM target_candidates_history").fetchall()]
|
|
print(cols_tc)
|
|
|
|
date_col_tc = 'scan_time' if 'scan_time' in cols_tc else ('created_at' if 'created_at' in cols_tc else 'ts')
|
|
tc_data = db.conn.execute(f"SELECT * FROM target_candidates_history WHERE date({date_col_tc}) = '2026-08-31'").fetchall()
|
|
print(f"Target Candidates count for today: {len(tc_data)}")
|
|
|
|
print("\n[WS Orderbook Cols]")
|
|
cols_ob = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM ws_orderbook").fetchall()]
|
|
print(cols_ob)
|
|
|
|
ts_col = 'ts' if 'ts' in cols_ob else ('timestamp' if 'timestamp' in cols_ob else 'snap_time')
|
|
|
|
zeros = db.conn.execute(f"""
|
|
SELECT count(*) as c
|
|
FROM ws_orderbook
|
|
WHERE date({ts_col}) = '2026-08-31'
|
|
AND (total_bid_qty = 0 OR total_ask_qty = 0 OR best_bid = 0 OR best_ask = 0)
|
|
""").fetchone()
|
|
print("Zeros count in KIS orderbook:", dict(zeros))
|
|
|
|
sample_zero = db.conn.execute(f"""
|
|
SELECT *
|
|
FROM ws_orderbook
|
|
WHERE date({ts_col}) = '2026-08-31'
|
|
AND (total_bid_qty = 0 OR total_ask_qty = 0 OR best_bid = 0 OR best_ask = 0)
|
|
LIMIT 1
|
|
""").fetchone()
|
|
if sample_zero:
|
|
print("Sample Zero:", dict(sample_zero))
|
|
|
|
finally:
|
|
db.close()
|