feat: Enhance trading system with new permanent subscription features and order book management

Changes:
- Added a new API endpoint for managing permanent subscriptions, allowing users to enable or disable subscriptions dynamically.
- Implemented a function to fill candle data from Kiwoom, ensuring that only relevant data is inserted into the database.
- Introduced a mechanism to handle master subscription states, improving the management of subscription statuses.
- Updated the database schema to include new fields for managing subscription states and order book filtering.

Impact:
- These enhancements improve the flexibility and reliability of the trading system, allowing for better management of subscriptions and order book data, while reducing the risk of data inconsistencies.

히스토리 align 제거 븅신같은 초기설계 아예 제거
진입모드에 구멍메움
호가진입을 켜도 호가가 안들어올때 호가 안보고 그냥 사버림
This commit is contained in:
Your Name
2026-08-15 23:01:14 +09:00
parent 4a18ce2697
commit 36a3e2b4a1
94 changed files with 6368 additions and 1639 deletions

View File

@@ -179,19 +179,18 @@ def query_condition_job_events(
def build_condition_parity_report(db, *, day: str) -> Dict[str, Any]:
"""전략별 live소스·history·job·ALIGN 정합 요약 (웹 탭용).
"""전략별 live소스·history·job 요약 (웹 탭용).
봇 RAM 은 웹에서 직접 못 읽으므로 **당일 history 최신 스냅샷** + job 집계로
구멍(LS history 공백·키움만 살아있음)을 가독성 있게 표시한다.
"""
from kis_trader.utils.env import get_env_bool, get_env_from_db
from kis_trader.utils.env import get_env_from_db
day_s = str(day or "").strip()[:10]
if len(day_s) != 10:
day_s = datetime.now().strftime("%Y-%m-%d")
start_s = day_s + " 00:00:00"
end_s = day_s + " 23:59:59"
align_on = get_env_bool("LIVE_UNIVERSE_SLOT_ALIGN", False)
end_s = day_s + " 23:59:59.999999"
sids = ("SCALP", "SHORT", "BREAKOUT", "MOMENTUM")
ensure_condition_job_events_table(db)
@@ -302,7 +301,7 @@ def build_condition_parity_report(db, *, day: str) -> Dict[str, Any]:
if live_src in ("ls_condition", "ls", "ls_afr"):
if (ls.get("n") or 0) <= 0:
status = "danger"
warn = "실매=LS 인데 당일 LS history 최신 스냅 0/없음 → 유니버스0·ALIGN 위험"
warn = "실매=LS 인데 당일 LS history 최신 스냅 0/없음 → 유니버스0 위험"
if (kw.get("n") or 0) > 0:
warn += f" (키움 history는 {kw['n']}종 있음 — t1859공백/AFR미적재 의심)"
elif ls.get("age_sec") is not None and ls["age_sec"] > 600:
@@ -319,7 +318,6 @@ def build_condition_parity_report(db, *, day: str) -> Dict[str, Any]:
strategies.append({
"strategy_id": sid,
"live_source": live_src,
"align_on": align_on,
"ls_hist_n": ls.get("n") or 0,
"ls_hist_at": ls.get("event_time"),
"ls_age_sec": ls.get("age_sec"),
@@ -338,13 +336,12 @@ def build_condition_parity_report(db, *, day: str) -> Dict[str, Any]:
return {
"day": day_s,
"align_on": align_on,
"grace_sec": grace_sec,
"strategies": strategies,
"timeline": timeline,
"notes": (
"history=봇이 저장한 effective 스냅. 실매 소스가 LS인데 LS history 0 이면 "
"universe_zero 알림이 정상(키움 이중이력과 무관). "
"ALIGN=ON 이면 live∩history — history 구멍 시 교집합 위험."
"history=봇이 저장한 effective 스냅. 실매 후보는 키움 RAM. "
"실매 소스가 LS인데 LS history 0 이면 universe_zero 알림이 정상"
"(키움 이중이력과 무관)."
),
}