refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.
This commit is contained in:
40
scratch/check_db_stats3.py
Normal file
40
scratch/check_db_stats3.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import sys
|
||||
import os
|
||||
import pymysql
|
||||
import json
|
||||
|
||||
sys.path.insert(0, '/home/hoon/kis_bot')
|
||||
from kis_trader.utils.env import get_env_from_db
|
||||
|
||||
host = "192.168.0.141"
|
||||
user = "kis"
|
||||
password = "kis"
|
||||
db_name = "kis_quant_db"
|
||||
|
||||
conn = pymysql.connect(host=host, user=user, password=password, database=db_name)
|
||||
today = "2026-08-11"
|
||||
|
||||
queries = {
|
||||
"trade_history": f"SELECT COUNT(*) FROM trade_history WHERE buy_date >= '{today} 00:00:00'",
|
||||
"kis_ws_orderbook": f"SELECT COUNT(*) FROM kis_ws_orderbook WHERE recv_ts >= '{today} 00:00:00'",
|
||||
"ls_ws_orderbook": f"SELECT COUNT(*) FROM ls_ws_orderbook WHERE recv_ts >= '{today} 00:00:00'",
|
||||
"ws_orderbook (키움)": f"SELECT COUNT(*) FROM ws_orderbook WHERE recv_ts >= '{today} 00:00:00'",
|
||||
"ls_ws_ticks": f"SELECT COUNT(*) FROM ls_ws_ticks WHERE ts >= '{today} 00:00:00'",
|
||||
"ws_ticks (키움/KIS)": f"SELECT COUNT(*) FROM ws_ticks WHERE recv_ts >= '{today} 00:00:00'",
|
||||
"ls_ws_candles": f"SELECT COUNT(*) FROM ls_ws_candles WHERE datetime >= '{today} 00:00:00'",
|
||||
"ws_candles (키움/KIS)": f"SELECT COUNT(*) FROM ws_candles WHERE candle_time >= '{today} 00:00:00'",
|
||||
}
|
||||
|
||||
results = {}
|
||||
with conn.cursor() as cur:
|
||||
for name, q in queries.items():
|
||||
try:
|
||||
cur.execute(q)
|
||||
res = cur.fetchone()
|
||||
results[name] = res[0]
|
||||
except Exception as e:
|
||||
results[name] = f"Error: {e}"
|
||||
|
||||
conn.close()
|
||||
for k, v in results.items():
|
||||
print(f"{k}: {v:,}" if isinstance(v, int) else f"{k}: {v}")
|
||||
Reference in New Issue
Block a user