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:
40
backend/tests/test_market_analyzer_volratio_r3.py
Normal file
40
backend/tests/test_market_analyzer_volratio_r3.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""거래량비 장중 시간 정규화 (하드닝 R3)."""
|
||||
from datetime import datetime
|
||||
from app.services import market_analyzer as ma
|
||||
|
||||
KST = ma.KST
|
||||
|
||||
|
||||
def _now(h, m, d=(2026, 10, 8)): # 목요일
|
||||
return KST.localize(datetime(d[0], d[1], d[2], h, m))
|
||||
|
||||
|
||||
def test_intraday_partial_bar_is_normalized():
|
||||
vols = [1000] * 20 + [250]
|
||||
r = ma._volume_ratio_v2(vols, 250, "20261008", _now(10, 37))
|
||||
assert 0.95 < r < 1.05
|
||||
assert 250 / (sum(vols[-20:]) / 20) < 0.3 # 기존 방식은 구조적으로 낮았다
|
||||
|
||||
|
||||
def test_today_bar_excluded_from_denominator():
|
||||
vols = [1000] * 20 + [10_000_000]
|
||||
r = ma._volume_ratio_v2(vols, 10_000_000, "20261008", _now(15, 29))
|
||||
assert r > 9000
|
||||
|
||||
|
||||
def test_early_open_fraction_floor():
|
||||
vols = [1000] * 21
|
||||
r = ma._volume_ratio_v2(vols, 10, "20261008", _now(9, 1))
|
||||
assert r == 10 / (1000 * ma._VOL_MIN_ELAPSED_FRACTION)
|
||||
|
||||
|
||||
def test_completed_or_past_bar_unchanged():
|
||||
vols = [1000] * 19 + [2000]
|
||||
legacy = 2000 / (sum(vols[-20:]) / 20)
|
||||
assert ma._volume_ratio_v2(vols, 2000, "20261008", _now(16, 0)) == legacy
|
||||
assert ma._volume_ratio_v2(vols, 2000, "20261007", _now(10, 0)) == legacy
|
||||
assert ma._volume_ratio_v2(vols, 2000, "20261010", _now(10, 0, (2026, 10, 10))) == legacy
|
||||
|
||||
|
||||
def test_insufficient_history():
|
||||
assert ma._volume_ratio_v2([1000] * 10, 5, "20261008", _now(10, 0)) == 0
|
||||
Reference in New Issue
Block a user