55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
import sys
|
|
import datetime
|
|
sys.path.insert(0, '/home/hoon/kis_bot')
|
|
from database import TradeDB
|
|
|
|
db = TradeDB()
|
|
|
|
# 오늘 날짜
|
|
today_str = "2026-08-11"
|
|
today_dt = datetime.datetime.strptime(today_str, "%Y-%m-%d")
|
|
|
|
# 테이블별 타임스탬프 컬럼
|
|
table_time_col = {
|
|
'trade_history': 'buy_date',
|
|
'ws_ticks': 'tick_time',
|
|
'ws_candles': 'start_time',
|
|
'ws_orderbook': 'recv_ts',
|
|
'kis_ws_orderbook': 'recv_ts',
|
|
'ls_ws_ticks': 'recv_ts',
|
|
'ls_ws_candles': 'recv_ts',
|
|
'ls_ws_orderbook': 'recv_ts'
|
|
}
|
|
|
|
print(f"| 증권사 | 데이터 유형 | 테이블명 | {today_str} 당일 적재 건수 |")
|
|
print("|---|---|---|---|")
|
|
|
|
for t, col in table_time_col.items():
|
|
try:
|
|
if t == 'trade_history':
|
|
sql = f"SELECT COUNT(*) as c FROM {t} WHERE DATE({col}) = %s"
|
|
params = (today_str,)
|
|
else:
|
|
sql = f"SELECT COUNT(*) as c FROM {t} WHERE {col} LIKE %s"
|
|
params = (f"{today_str}%",)
|
|
|
|
res = db.conn.execute(sql, params).fetchone()
|
|
count = dict(res)['c']
|
|
|
|
broker = "공통"
|
|
if "ls_" in t:
|
|
broker = "LS증권"
|
|
elif "kis_" in t or t in ['ws_ticks', 'ws_candles', 'ws_orderbook']:
|
|
broker = "한국투자증권(KIS) / 키움"
|
|
|
|
data_type = "매매내역"
|
|
if "tick" in t: data_type = "실시간 체결 틱"
|
|
elif "candle" in t: data_type = "실시간 캔들 (분봉)"
|
|
elif "orderbook" in t: data_type = "호가 스냅샷 (Orderbook)"
|
|
|
|
print(f"| {broker} | {data_type} | `{t}` | {count:,} 건 |")
|
|
except Exception as e:
|
|
print(f"| - | - | `{t}` | 에러: {e} |")
|
|
|
|
db.close()
|