NXT 시간외 거래 시간대도 5분 cron 폴링 활성화. 23:30-04:30 dead zone
(KIS 점검) → 04:30 까지 skip. 기존 _seconds_until_next_market_open
(휴장일/주말용) 와 별개로 _seconds_until_nxt_or_market_open 신설.
3 new tests, scheduler suite 11 passed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- holidays.json: authoritative copy from web-backend/stock/app/holidays.json
(replaces 13-date stub from Task 3; now 16 dates including Jan/May/Dec edges)
- start.bat: uvicorn launcher (cd to web-ai root, host 0.0.0.0, port 8001)
19 tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
poll_loop: asyncio.gather parallel fetch of 3 endpoints (portfolio,
news_sentiment, screener_preview) + state update. main.py: FastAPI
lifespan creates StockClient/SignalDedup/shutdown.Event then spawns
poll_loop as background task. GET /health reports status, last poll
times, cache size.
Signal V2 test suite: 19/19 PASS.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SignalDedup: 24h-rolling duplicate signal blocker. SQLite WAL +
busy_timeout=120000 standard fix (reference_sqlite_concurrency.md
pattern). PK (ticker, action) with UPSERT. Phase 4 (signal generator)
will call is_recent() before sending + record() after sending.
3 unit tests pass, total 17 signal_v2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Time-window dispatcher: pre-market (07:00-09:00, 5min), market
(09:00-15:30, 1min), post-market (15:30-20:00, 5min), overnight skip
to next market day 07:00. Weekend + holiday detection via holidays.json.
Stub holidays.json with 13 dates. Task 6 will sync from
web-backend/stock/app/holidays.json.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 files had insufficient .parent count, resolving to signal_v1/.env
instead of web-ai/.env (which is where the actual env file lives).
Added one .parent each:
- config.py: parent.parent → parent.parent.parent
- analysis/macro.py: parent.parent.parent → parent.parent.parent.parent
- services/telegram_bot/runner.py: parent.parent.parent.parent → +1
watchlist_manager.py was already correct.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- DailyLedger: 당일 매수 회계 + 연속 손절 카운터 + 매수 신호 점수 한 객체로 집약 (bot.py 정리)
- RiskGate: 테마당 동시 보유 + 노출 비율 상한 검증 (포트폴리오 레벨)
- news_snapshot: 뉴스 SQLite 영구 저장 + 사후 감성 재검증 인프라
- backtest_runner: 전 종목 KIS 일봉 기반 백테스트 (Sharpe/MDD/Calmar)
- bot.py 274 line 정리 (DailyLedger 분리)
- backtest.py 173 line 재작성 (v3.2 next-bar 체결 + 거래세)
- daily_launcher.py 폐기 (warmup_and_restart 통합)
- .gitignore: .claude/ 제외
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
[잔고 관리]
- _today_buy_total 인스턴스 변수로 당일 누적 매수 추적 (KIS T+2 미차감 보완)
- MAX_BUY_PER_CYCLE, MAX_DAILY_BUY_RATIO 설정 추가
- available_deposit = max_daily_buy - effective_today_buy 계산
[앙상블 & 포지션 사이징]
- AdaptiveEnsemble 실제 연동 (하드코딩 가중치 제거)
- Kelly Criterion Half-Kelly 포지션 비중 계산
- SignalWeights.normalize() Water-Filling 알고리즘으로 경계 위반 해결
- _accuracy_weighted() 크기 가중 정확도로 통일
- ensemble_weights.json → ensemble_history.json 통합
[LLM 클라이언트]
- GeminiLLMClient 추가 (Gemini → Ollama 폴백 체인)
- _class_last_call_ts 클래스 변수로 워커 재시작 후에도 스로틀 유지
- Ollama 미실행 조기 감지 및 명확한 오류 메시지
[KIS API]
- 모든 requests.get/post에 timeout=Config.HTTP_TIMEOUT 적용
- get_balance()에 today_buy_amt 필드 추가
[장중 전용 운영]
- KRXCalendar: exchange_calendars 기반, 2024~2026 공휴일 하드코딩 폴백
- EOD 셧다운: 15:35에 전체 상태 저장 후 서버 자동 종료
- Watchdog: .eod_date 마커로 EOD 후 재시작 차단
- daily_launcher.py: 매일 08:30 실행, 휴장일 감지 후 봇 미시작
- Windows 작업 스케줄러 WebAI_DailyLauncher 등록
[텔레그램 스킬 수정]
- PYTHONIOENCODING=utf-8 서브프로세스 환경 설정 (cp949 이모지 오류 해결)
- /regime: IPC macro_indices 파싱 구현, --json 모드 input() 블로킹 제거
- /weights: ensemble_history.json 형식 파싱 업데이트
- /model_health: glob 패턴 *_v3.pt 수정
- /postmortem: 거래 없을 때 빈 JSON 출력으로 Telegram 오류 해결
- /macro: price=0 시 prev_close 폴백 표시
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- analysis/backtest.py: 백테스팅 프레임워크 신규 추가
- analysis/ensemble.py: 적응형 앙상블 가중치 신규 추가
- warmup_and_restart.py: 봇 워밍업 및 재시작 스크립트 신규 추가
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- modules/utils/performance_db.py 신규: 일별 자산 스냅샷(16:00~16:30) 및
매매 기록 영구 저장 (PerformanceDB 클래스)
- modules/analysis/evaluator.py 신규: Sharpe/Sortino/MDD/Alpha 등 16개 지표 산출,
S~F 등급 시스템, Ollama 5명 전문가 패널, 텔레그램 HTML 주간 보고서 (PerformanceEvaluator 클래스)
- modules/bot.py 수정: BUY/SELL 시 perf_db 기록 강화, 금요일 15:35 주간 평가 자동 실행,
IPC 'evaluate' 명령 처리
- modules/services/telegram_bot/server.py 수정: /evaluate 명령어 추가
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>