- _parse_exit_type: '시간 손절'/'시간손절'/time_stop → time_stop (이전엔 '손절' 글자로 stop_loss 로 분류돼 -0.1% 시간손절이 '-6% 손절 도달'로 표시되고 손절 비율 인사이트가 부풀었다) - 일지 청산 설명의 하드코딩(-6%, RSI 65+, 1.5×ATR)을 settings 실효값으로(§4) - 분석 화면 청산 유형 한글 표시명 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
"""시간손절이 '손절(stop_loss)'로 분류·서술되던 문제 (2026-10-07)."""
|
|
from app.core.config import settings
|
|
from app.services.day_trading_strategy import TIME_STOP_REASON_PREFIX
|
|
from app.services.trade_analyzer import _parse_exit_type
|
|
|
|
|
|
def test_dt_time_stop_reason_is_time_stop():
|
|
reason = f"{TIME_STOP_REASON_PREFIX}: 32분 경과, 수익=-0.4% < {settings.DAY_TRADE_TIME_STOP_MIN_GAIN * 100:.1f}%"
|
|
assert _parse_exit_type(reason) == "time_stop"
|
|
|
|
|
|
def test_swing_time_stop_reason_is_time_stop():
|
|
assert _parse_exit_type("시간손절: 20거래일 보유, 수익 1.2% < 3%") == "time_stop"
|
|
|
|
|
|
def test_real_stop_loss_still_stop_loss():
|
|
assert _parse_exit_type("손절: -7.2% (기준 -7%)") == "stop_loss"
|
|
assert _parse_exit_type("stop_loss hit") == "stop_loss"
|
|
|
|
|
|
def test_journal_comment_uses_settings_not_hardcoded():
|
|
import inspect
|
|
from app.services import trade_analyzer
|
|
|
|
src = inspect.getsource(trade_analyzer)
|
|
assert "손절 기준(-6%" not in src # 옛 하드코딩 서술 제거
|
|
assert "RSI 65+" not in src
|