fix(P0): 인증 누락·레거시 DT 엔진 병존·혼재 종목 재태깅·자정 후 스테일 청산 무력화
감사 CRITICAL 4건:
- /daytrading/{watchlist,execute,close-all,cycle} 에 require_api_key 누락 → 인증 없이
전량 청산 가능했음 (CLAUDE.md §4 위반)
- 레거시 day_trading._positions 가 엔진 day_trading_state 와 별도로 기동 시 복원돼
같은 포지션이 두 엔진에 존재 → /close-all 시 이중 매도. 복원 제거 + close-all/cycle 을
엔진에 위임, /execute 실매수는 410(엔진 미관리 포지션 방지)
- reflect_buy 가 기존 행을 daytrading 으로 재태깅 → 같은 종목 스윙 보유분이
get_swing_holdings 에서 빠져 손절·익절 정지. 신규 행일 때만 태깅
- close_stale_positions 가 인메모리만 순회 → 자정 reset 후 대상이 사라져 무력.
ActiveTrade(day_trade/active/전일) 조회 기반으로 변경하고 인메모리가 비어도 실행
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -215,11 +215,9 @@ async def lifespan(app: FastAPI):
|
||||
except Exception as e:
|
||||
logger.warning(f"⚠️ [KRX] 초기 데이터 확인 실패 (non-critical): {e}")
|
||||
|
||||
try:
|
||||
from app.api.endpoints.day_trading import restore_positions_from_db
|
||||
await restore_positions_from_db()
|
||||
except Exception as e:
|
||||
logger.warning(f"⚠️ 데이트레이딩 포지션 복구 실패 (non-critical): {e}")
|
||||
# [2026-09-23] 레거시 day_trading._positions 복원 제거.
|
||||
# services/daytrading/scheduler 가 day_trading_state 로 복원하므로, 둘 다 복원하면
|
||||
# 같은 포지션이 두 엔진에 존재해 이중 매도가 발생한다.
|
||||
|
||||
# ── httpx 싱글톤 클라이언트 초기화 ──────────────────────────────────────
|
||||
from app.api.endpoints.mcp import init_http_client, close_http_client
|
||||
|
||||
Reference in New Issue
Block a user