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

@@ -18,7 +18,11 @@ from sqlalchemy import select, update
from app.core.database import AsyncSessionLocal
from app.models.models import StrategyConfig
from app.services.strategy_config_service import strategy_cfg
from app.services.strategy_config_service import (
get_effective_dt_params_v2,
serialize_config_v2,
strategy_cfg,
)
router = APIRouter()
logger = logging.getLogger(__name__)
@@ -39,6 +43,7 @@ class StrategyConfigResponse(BaseModel):
max_value: Optional[str]
is_active: bool
updated_by: Optional[str]
read_only: bool = False
class Config:
from_attributes = True
@@ -74,7 +79,7 @@ async def list_configs(
if active_only:
stmt = stmt.where(StrategyConfig.is_active == True)
result = await session.execute(stmt)
return result.scalars().all()
return [serialize_config_v2(c) for c in result.scalars().all()]
@router.get("/groups", response_model=List[str])
@@ -83,6 +88,12 @@ async def list_groups():
return ["INDICATOR", "RISK", "FILTER", "DAY_TRADE", "MEAN_REVERSION", "GENERAL"]
@router.get("/dt-effective", response_model=Dict[str, Any])
async def get_dt_effective():
"""DT 엔진이 실제로 쓰는 값(settings 단일 소스). 읽기 전용."""
return get_effective_dt_params_v2()
@router.get("/cache-snapshot", response_model=Dict[str, Any])
async def get_cache_snapshot():
"""현재 인메모리 캐시 상태 조회 (디버그용)."""
@@ -99,7 +110,7 @@ async def get_config(key: str):
cfg = result.scalar_one_or_none()
if not cfg:
raise HTTPException(status_code=404, detail=f"파라미터 '{key}'를 찾을 수 없습니다.")
return cfg
return serialize_config_v2(cfg)
@router.put("/{key}", response_model=StrategyConfigResponse)
@@ -134,7 +145,10 @@ async def bulk_update(body: BulkUpdateRequest):
@router.post("/{key}/reset", response_model=StrategyConfigResponse)
async def reset_config(key: str):
"""단일 파라미터를 기본값으로 리셋."""
cfg = await strategy_cfg.reset_to_default(key)
try:
cfg = await strategy_cfg.reset_to_default(key)
except ValueError as e:
raise HTTPException(status_code=422, detail=str(e))
if not cfg:
raise HTTPException(status_code=404, detail=f"파라미터 '{key}'를 찾을 수 없습니다.")
return cfg