Fix '지금 시작': immediately run breakout check after ORB detection

Previously run_session_now() only ran orb_detect and injected future
scheduled events, but scheduled breakout windows were already past so
no breakout check ever fired.

Now: after orb_detect, immediately run one breakout check with current
snapshot prices (the core of '지금 시작'). All scheduled breakout events
are marked completed. Only stop_check and eod_exit events are injected
into the live schedule going forward.

Also improve alert message to clarify background execution (~1-2 min).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
I Luk Kim 4 months ago
parent 55a9618b20
commit 407238e5d5

@ -509,10 +509,17 @@ class ORBAutoScheduler:
self._log(f"🔄 지금 시작: {session_name} — ORB 감지 실행 중 (현재 시세 기준)...")
# Run detection now (blocking in thread so we don't stall the event loop)
# Phase 1: Run ORB detection (fetches historical bars for ORB window)
await self._run_trading("orb_detect", [session_name], date_str)
# Inject remaining future events into the live schedule
# Phase 2: Immediately check for breakouts using current snapshot prices.
# This is the "지금 시작" core — regardless of whether scheduled breakout
# windows have already passed, we check current price right now.
self._log(f"🔍 {session_name}: 현재 가격으로 브레이크아웃 즉시 체크...")
await self._run_trading("breakout", [session_name], date_str)
# Phase 3: Inject remaining future events (stop checks + EOD exit only).
# Skip all breakout events — we just ran the manual check above.
params = _load_session_params(self._db_path, session_name)
all_events = build_schedule(today, **params)
for ev in all_events:
@ -522,15 +529,17 @@ class ORBAutoScheduler:
existing_names = {e["name"] for e in self._today_schedule}
injected = 0
for ev in all_events:
if ev["et_dt"] <= now_et:
# Past events: mark as completed so the loop skips them
if ev["kind"] == "breakout":
# Already handled by the manual check above
self._completed.add(ev["name"])
elif ev["et_dt"] <= now_et:
self._completed.add(ev["name"])
elif ev["name"] not in existing_names:
self._today_schedule.append(ev)
injected += 1
self._today_schedule.sort(key=lambda e: (e["et_dt"], e.get("session", "")))
self._log(f"{session_name}: {injected} 이벤트 추가됨 (오늘 남은 일정 포함)")
self._log(f"{session_name}: {injected} 이벤트 추가됨 (스톱/EOD 일정)")
return {"session": session_name, "injected": injected}

File diff suppressed because one or more lines are too long

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fithia2</title>
<script type="module" crossorigin src="/assets/index-2wtBT0D_.js"></script>
<script type="module" crossorigin src="/assets/index-BoVqCuLt.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-AVDbFxMk.css">
</head>
<body>

@ -794,7 +794,9 @@ export function OrbTradingPage() {
onSuccess: (result) => {
qc.invalidateQueries({ queryKey: ['orb-sessions'] });
qc.invalidateQueries({ queryKey: ['orb-auto-status'] });
alert(`${result.session_name}: ${result.note}`);
alert(`${result.session_name} 백그라운드 시작됨\n\n` +
`ORB 감지 → 브레이크아웃 체크 순으로 실행됩니다 (약 1~2분 소요).\n` +
`스케줄러 로그에서 진행상황을 확인하세요.`);
},
onError: (e: Error) => alert(`지금 시작 실패: ${e.message}`),
});

Loading…
Cancel
Save