fix: 장 마감 중 30분 sleep이 09:00 개장을 건너뛰어 ORB 수집 누락
데이트레이딩 스케줄러는 장 마감 시 무조건 1800초를 자서, 08:31~09:00 사이에 잠들면 09:01~09:30에 깨어나 ORB 수집 구간(09:00~09:30)을 통째로 놓쳤음(2026-09-23 감시종목 0 확인). - market_schedule.seconds_until_market_open() 추가 (주말·공휴일 건너뜀) - 스케줄러: 마감 중 sleep = min(1800, 개장까지 남은 시간), 개장 3분 전 watchlist 선구성 - 회귀 테스트 4건 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ from app.core.config import settings
|
||||
from app.core.market_schedule import (
|
||||
is_market_open, is_opening_range_period,
|
||||
is_day_trade_entry_window, is_eod_flat_time,
|
||||
seconds_until_market_open,
|
||||
)
|
||||
from app.services.mdd_manager import mdd_manager
|
||||
from app.services.daytrading.position_manager import day_trading_state
|
||||
@@ -75,7 +76,19 @@ async def daytrading_scheduler() -> None:
|
||||
day_trading_state.reset_if_new_day()
|
||||
|
||||
if not is_market_open():
|
||||
await asyncio.sleep(1800)
|
||||
# [FIX 2026-09-23] 고정 1800초 sleep은 09:00 개장을 건너뛰어
|
||||
# ORB 수집(09:00~09:30)을 통째로 놓칠 수 있다 → 개장까지 남은 시간만큼만 대기.
|
||||
_until_open = seconds_until_market_open()
|
||||
# 개장 3분 전이면 watchlist를 미리 채워 09:00부터 ORB 수집 가능
|
||||
if _until_open is not None and _until_open <= 180 and not get_watchlist():
|
||||
try:
|
||||
count = await populate_daytrading_watchlist()
|
||||
if count:
|
||||
logger.info(f"[DayTrading] 개장 전 watchlist 선구성: {count}개")
|
||||
except Exception as e:
|
||||
logger.warning(f"[DayTrading] 개장 전 watchlist 구성 실패: {e}")
|
||||
_sleep = 1800.0 if _until_open is None else max(15.0, min(1800.0, _until_open))
|
||||
await asyncio.sleep(_sleep)
|
||||
continue
|
||||
|
||||
if not settings.DAY_TRADE_ENABLED:
|
||||
|
||||
Reference in New Issue
Block a user