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:
54
backend/tests/test_trades_delete_pending_keeps_pending_r7.py
Normal file
54
backend/tests/test_trades_delete_pending_keeps_pending_r7.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""R7: DELETE /trades/pending(+v2) 는 PENDING 을 지우지 않는다 (원장 BUY 합계·강등 방어 근거)."""
|
||||
import pytest
|
||||
from types import SimpleNamespace
|
||||
|
||||
|
||||
class _Res:
|
||||
def __init__(self, rows):
|
||||
self._rows = rows
|
||||
|
||||
def scalars(self):
|
||||
return SimpleNamespace(all=lambda: self._rows)
|
||||
|
||||
|
||||
class _DB:
|
||||
def __init__(self):
|
||||
self.stmts, self.deleted = [], []
|
||||
|
||||
async def execute(self, stmt):
|
||||
self.stmts.append(stmt)
|
||||
return _Res([])
|
||||
|
||||
async def delete(self, obj):
|
||||
self.deleted.append(obj)
|
||||
|
||||
async def commit(self):
|
||||
return None
|
||||
|
||||
|
||||
def _params(stmt):
|
||||
return [str(v) for v in stmt.compile().params.values()]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_v1_only_failed_before_today():
|
||||
from app.api.endpoints import trades as tr
|
||||
db = _DB()
|
||||
await tr.delete_pending_trades(db=db)
|
||||
p = _params(db.stmts[0])
|
||||
assert "FAILED" in p and "PENDING" not in p
|
||||
assert "created_at <" in str(db.stmts[0].compile())
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_v2_only_failed_before_today(monkeypatch):
|
||||
from app.api.endpoints import trades_v2 as t2
|
||||
|
||||
async def _uid(*a, **k):
|
||||
return None
|
||||
monkeypatch.setattr(t2, "_resolve_target_user_id", _uid)
|
||||
db = _DB()
|
||||
await t2.delete_pending_trades_v2(user=SimpleNamespace(), db=db)
|
||||
p = _params(db.stmts[0])
|
||||
assert "FAILED" in p and "PENDING" not in p
|
||||
assert "created_at <" in str(db.stmts[0].compile())
|
||||
Reference in New Issue
Block a user