Files
kis_bot/scratch/kiwoom_silence_overlap.py
Your Name 0ecac7cb95 이번에 들어간 내용
한투 호가 = 2번째 앱키 전용
키 없거나 start 실패 시 메인에 H0STASP0 안 붙임. 운영설정 WS_ORDERBOOK_SAVE_KIS 빨간 danger.

LS RAM 합집합
후보∪보유∪영구∪grace. sync_targets와 split reconcile 둘 다. 틱 DB 영구 게이트는 그대로.

분봉 쓰레기 → 다음 소스 봉 통째
그 분 틱 0건이거나 전부 봉끝 대비 LIVE_FEED_FALLBACK_MAX_AGE_SEC 초과면 구멍. 메인 WS → 2차 → LS → REST → rollup. CANDLE_GARBAGE_FALLBACK 기본 true.

파일: feed_fallback.py(신규), ws_manager.py, kis_ws.py, candle_series.py, bt_candle_source.py, live_config_schema.py, database.py, 스모크, MD 2개.

같은 ws_manager/database/kis_ws/live_config에는 직전 커밋 이후 쌓여 있던 시세 폴백·ENV 키 정리도 같이 들어갔습니다. 파일 단위로 나눌 수 없어서입니다.
2026-08-19 22:11:31 +09:00

53 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""키움 전종목 침묵 구간의 한투 틱이 키움 구독 종목인지."""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from database import TradeDB
db = TradeDB()
windows = [
("2026-08-19 09:05:07", "2026-08-19 09:05:33"),
("2026-08-19 09:08:50", "2026-08-19 09:09:01"),
("2026-08-19 09:11:09", "2026-08-19 09:14:55"),
("2026-08-19 09:14:57", "2026-08-19 09:19:11"),
("2026-08-19 09:27:24", "2026-08-19 09:31:32"),
]
kw_codes = {
r["code"]
for r in db.conn.execute(
"SELECT DISTINCT code FROM ws_ticks WHERE source=%s AND recv_ts >= %s AND recv_ts < %s",
("kiwoom", "2026-08-19 09:00:00", "2026-08-19 09:35:00"),
).fetchall()
}
print("kiwoom codes today morning", len(kw_codes))
for a, b in windows:
rows = db.conn.execute(
"SELECT code, COUNT(*) n FROM ws_ticks WHERE source=%s AND recv_ts >= %s AND recv_ts <= %s "
"GROUP BY code ORDER BY n DESC LIMIT 8",
("kis", a, b),
).fetchall()
tot = db.conn.execute(
"SELECT COUNT(*) n, COUNT(DISTINCT code) codes FROM ws_ticks "
"WHERE source=%s AND recv_ts >= %s AND recv_ts <= %s",
("kis", a, b),
).fetchone()
overlap_n = 0
overlap_codes = 0
for r in db.conn.execute(
"SELECT code, COUNT(*) n FROM ws_ticks WHERE source=%s AND recv_ts >= %s AND recv_ts <= %s GROUP BY code",
("kis", a, b),
).fetchall():
if r["code"] in kw_codes:
overlap_n += int(r["n"])
overlap_codes += 1
print(f"\n{a} ~ {b}")
print(" kis", dict(tot), "overlap_kw_univ ticks", overlap_n, "codes", overlap_codes)
print(" top", [dict(x) for x in rows[:5]])