fix: 하드닝 루프 8회차 — 체결 보정·고아 감지·청산 경보·실시간/차트·리스크 가드 일괄 수정

- 스윙 체결가 확인 전 executed_price NULL + fill_sweep, 진입가 resolve(ActiveTrade↔Portfolio), 0체결/부분체결 매수 장부 원복
- DT 고아 감지(근거 한정)·0체결 매도 복원·stale 점검 확대, 시간손절 -0.3% 원복
- 폴백 손절 ATR 캐시, 거래량부족-차단 신호 매수 차단, 현금 5% 유보 재적용, MDD peak/reset 수정
- KIS 서킷브레이커 청산 우회·경보, db_worker 재큐잉 순서, heartbeat·health-watch 사이드카
- 실시간 WS 재구독·41건 우선순위·다건 프레임 분할, 차트 샘플 제거·당일봉 합성, WS 서브프로토콜 인증
- 프론트: 미관리 그룹·확인 모달·차트 실시간 반영·예수금 표시 정정
- 전문가 에이전트 6종 추가(.claude/agents)
- 유닛 스위트 2667 passed (소켓 차단 하), tsc OK

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y83Za98XsNw9zuA4FTUytN
This commit is contained in:
2026-10-10 12:17:49 +09:00
parent 5c4803b339
commit a264561576
230 changed files with 41160 additions and 2334 deletions

View File

@@ -135,6 +135,18 @@ services:
condition: service_healthy
mcp-server:
condition: service_started
# [R2 M] 프로세스 밖 생존 감시: 이벤트 루프 hang / uvicorn 무응답을 컨테이너 상태(unhealthy)로 노출.
# 판정은 "10초 내 HTTP 200 응답"만 본다 — /health 의 status=degraded(DB 순간 장애·장외 stale)로
# unhealthy 가 되면 오탐이 잦다. degraded/schedulers.stale 감시는 앱 밖 cron 의 몫:
# scripts/health_watch.py (평일 장중 5분 cron, 연속 이상 시 텔레그램) + .claude/scripts/prod_smoke.sh 의 /health 확인.
# 위 cron 대신 compose 사이드카 health-watch 가 같은 스크립트를 돌린다(NAS cron 등록 불필요).
# (plain compose 는 unhealthy 컨테이너를 재시작하지 않는다 — 경보·수동 확인용 표식)
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=10).status == 200 else 1)"]
interval: 60s
timeout: 15s
retries: 3
start_period: 120s
restart: unless-stopped
deploy:
resources:
@@ -165,6 +177,45 @@ services:
condition: service_healthy
restart: unless-stopped
# /health 능동 감시 사이드카 — NAS cron 등록 여부에 의존하지 않도록 compose 안에서 직접 돈다.
# 평일(KST) 09~15시 5분 주기로 scripts/health_watch.py 실행(상태 전이 시 텔레그램). 장외는 stale 오탐 방지로 건너뜀.
# 상태 파일은 named volume 에 유지(재기동해도 연속 이상 카운트 보존).
# 마지막 실행 시각: `docker exec autostock-health-watch cat /state/last_run` (배포 스모크에서 mtime 확인용).
health-watch:
image: python:3.11-slim
container_name: autostock-health-watch
environment:
- TZ=Asia/Seoul
- HEALTH_URL=http://backend:8000/health
- HEALTH_WATCH_STATE=/state/health_watch.json
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN:-}
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-}
volumes:
- ./scripts/health_watch.py:/app/health_watch.py:ro
- health_watch_state:/state
command:
- sh
- -c
- |
while true; do
k=$$(date -u -d '+9 hours' '+%u %H')
dow=$${k% *}; hh=$${k#* }
if [ "$$dow" -le 5 ] && [ "$$((10#$$hh))" -ge 9 ] && [ "$$((10#$$hh))" -le 15 ]; then
python /app/health_watch.py || true
date -u '+%Y-%m-%dT%H:%M:%SZ' > /state/last_run
fi
sleep 300
done
networks:
- autostock-network
depends_on:
- backend
restart: unless-stopped
deploy:
resources:
limits:
memory: 64M
# Frontend
frontend:
build:
@@ -193,6 +244,7 @@ volumes:
redis_data:
rabbitmq_data:
backup_data:
health_watch_state:
networks:
autostock-network: