M1 │ 스캐너 최소 거래량 100만→10만주 │ kosdaq_scanner.py │
Some checks failed
CI/CD Pipeline / test-backend (push) Has been cancelled
CI/CD Pipeline / test-frontend (push) Has been cancelled
CI/CD Pipeline / build-and-push (push) Has been cancelled

├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M2  │ ADX 히스테리시스 18/22 (플리핑 방지)                │ mean_reversion_strategy.py     │
  ├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M3  │ 분할매도 최소 수익 1.0%→0.5%                        │ mean_reversion_strategy.py     │
  ├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M4  │ ORB 갭 필터 4% + 레인지 폭 0.3% 최소                │ day_trading_strategy.py        │
  ├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M5  │ 쿨다운 스트릭 부분매도 시 미변경                    │ daytrading/position_manager.py │
  ├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M6  │ MDD 강제매도 loss_tracker 기록 제거 (허위 ban 방지) │ mdd_manager.py                 │
  ├─────┼─────────────────────────────────────────────────────┼────────────────────────────────┤
  │ M7  │ RSI Wilder 스무딩으로 통일                          │ mean_reversion_strategy.py
This commit is contained in:
2026-04-03 11:41:52 +09:00
parent eda5d76af9
commit 9d096ddd57
22 changed files with 299 additions and 132 deletions

View File

@@ -153,20 +153,26 @@ class DayTradingState:
self.portfolio_cache_dirty = True
return pos
def update_pnl(self, realized: float) -> None:
def update_pnl(self, realized: float, is_full_close: bool = True) -> None:
"""실현 손익 누적 및 연속 손실 카운트 업데이트.
손실 시 loss_streak_today 증가, 이익 시 리셋.
3연패 이상이면 is_cooldown_active()가 True 반환.
연속 손실 카운트는 전량 매도(is_full_close=True)일 때만 업데이트.
분할 매도(is_full_close=False)나 손익분기(realized==0)는 카운트에 영향 없음.
Args:
realized: 실현 손익 (원). 양수=이익, 음수=손실
is_full_close: 전량 매도 여부. False이면 streak 카운트 미변경
"""
self.daily_pnl += realized
if not is_full_close:
return
if realized < 0:
self.loss_streak_today += 1
else:
# 이익 발생 시 연속 손실 카운트 리셋
elif realized > 0:
# 이익 발생 시 연속 손실 카운트 리셋 (손익분기 realized==0은 중립 — 리셋하지 않음)
self.loss_streak_today = 0
def get_position(self, stock_code: str) -> dict | None: