[2026-06-06] SL cascade 진입 차단 적용

This commit is contained in:
2026-06-06 12:28:13 +09:00
parent bff0005322
commit 56385527ca
5 changed files with 25 additions and 5 deletions
+5
View File
@@ -80,6 +80,11 @@ Highest-leverage fixes:
- `TIME` and `FORCE` cooldown is based on final exit time, not entry time. - `TIME` and `FORCE` cooldown is based on final exit time, not entry time.
- Final `TP1`/`TP2` exits block same-day re-entry for that ticker. - Final `TP1`/`TP2` exits block same-day re-entry for that ticker.
- Re-entry control state is restored from today's DB rows after restart. - Re-entry control state is restored from today's DB rows after restart.
- SL cascade halt is active:
- `SL_CASCADE_HALT_THRESHOLD = 5`
- `SL_CASCADE_WINDOW_MIN = 60`
- New entries stop when the threshold is reached; existing positions keep
normal exit handling.
- Duplicate bot execution guards are active: - Duplicate bot execution guards are active:
- `app/main.py` uses `SingleInstanceLock` on `logs/stockbot.lock`. - `app/main.py` uses `SingleInstanceLock` on `logs/stockbot.lock`.
- `scripts/start_bot.py` stops the PID-file process and scans for existing - `scripts/start_bot.py` stops the PID-file process and scans for existing
+5
View File
@@ -80,6 +80,11 @@ Highest-leverage fixes:
- `TIME` and `FORCE` cooldown is based on final exit time, not entry time. - `TIME` and `FORCE` cooldown is based on final exit time, not entry time.
- Final `TP1`/`TP2` exits block same-day re-entry for that ticker. - Final `TP1`/`TP2` exits block same-day re-entry for that ticker.
- Re-entry control state is restored from today's DB rows after restart. - Re-entry control state is restored from today's DB rows after restart.
- SL cascade halt is active:
- `SL_CASCADE_HALT_THRESHOLD = 5`
- `SL_CASCADE_WINDOW_MIN = 60`
- New entries stop when the threshold is reached; existing positions keep
normal exit handling.
- Duplicate bot execution guards are active: - Duplicate bot execution guards are active:
- `app/main.py` uses `SingleInstanceLock` on `logs/stockbot.lock`. - `app/main.py` uses `SingleInstanceLock` on `logs/stockbot.lock`.
- `scripts/start_bot.py` stops the PID-file process and scans for existing - `scripts/start_bot.py` stops the PID-file process and scans for existing
+2
View File
@@ -21,6 +21,8 @@ MAX_POSITIONS = 2
ENTRY_LIMIT_ENFORCE = False ENTRY_LIMIT_ENFORCE = False
MAX_DAILY_ENTRIES = 30 MAX_DAILY_ENTRIES = 30
MAX_HOURLY_STOP_LOSS = 4 MAX_HOURLY_STOP_LOSS = 4
SL_CASCADE_WINDOW_MIN = 60
SL_CASCADE_HALT_THRESHOLD = 5
ENTRY_PAUSE_WINDOWS = ( ENTRY_PAUSE_WINDOWS = (
("11:00", "11:20"), ("11:00", "11:20"),
("14:00", "15:30"), ("14:00", "15:30"),
+9 -1
View File
@@ -81,7 +81,8 @@ from app.config import (
MAX_UNIVERSE, FORCE_EXIT, MAX_POSITIONS, MAX_UNIVERSE, FORCE_EXIT, MAX_POSITIONS,
MAX_HOLD_MIN, KOSPI_MIN_CHG, MAX_DAILY_ENTRIES, MAX_HOLD_MIN, KOSPI_MIN_CHG, MAX_DAILY_ENTRIES,
MAX_HOURLY_STOP_LOSS, ENTRY_PAUSE_WINDOWS, MAX_HOURLY_STOP_LOSS, ENTRY_PAUSE_WINDOWS,
ENTRY_LIMIT_ENFORCE ENTRY_LIMIT_ENFORCE, SL_CASCADE_WINDOW_MIN,
SL_CASCADE_HALT_THRESHOLD
) )
@@ -242,6 +243,13 @@ class StockBot:
if ENTRY_LIMIT_ENFORCE and entries >= MAX_DAILY_ENTRIES: if ENTRY_LIMIT_ENFORCE and entries >= MAX_DAILY_ENTRIES:
return f"daily entry limit reached {entries}/{MAX_DAILY_ENTRIES}" return f"daily entry limit reached {entries}/{MAX_DAILY_ENTRIES}"
cascade_stop_losses = self._recent_stop_loss_count(SL_CASCADE_WINDOW_MIN)
if cascade_stop_losses >= SL_CASCADE_HALT_THRESHOLD:
return (
f"cascade halt: {cascade_stop_losses} stop losses in last "
f"{SL_CASCADE_WINDOW_MIN} minutes"
)
stop_losses = self._recent_stop_loss_count(60) stop_losses = self._recent_stop_loss_count(60)
if ENTRY_LIMIT_ENFORCE and stop_losses >= MAX_HOURLY_STOP_LOSS: if ENTRY_LIMIT_ENFORCE and stop_losses >= MAX_HOURLY_STOP_LOSS:
return f"{stop_losses} stop losses in last 60 minutes" return f"{stop_losses} stop losses in last 60 minutes"
@@ -1,6 +1,6 @@
# 전략 개선 제안서 — 2026-06-05 # 전략 개선 제안서 — 2026-06-05
> 상태: 수동 승인 대기 > 상태: 적용 완료 (2026-06-06 사용자 승인)
> 근거: 12거래일 / 168회 거래 > 근거: 12거래일 / 168회 거래
> 증거 충분도: **부족 (30거래일 미만)** — 참고용, 적용 전 신중 검토 필요 > 증거 충분도: **부족 (30거래일 미만)** — 참고용, 적용 전 신중 검토 필요
@@ -69,9 +69,9 @@ if recent_sl_count >= CONSEC_SL_HALT_THRESHOLD:
### 예상 효과 ### 예상 효과
오늘 기준: threshold=5 적용 시 09:34 이후 신규 진입 중단 가능 오늘 기준: threshold=5 적용 시 09:36 이후 신규 진입 중단 가능
→ 차단 가능 손실: SK증권(-6,312) + 아리바이오랩(-6,303) + 디앤디파마텍(-5,947) + 이후 4건 → 차단 가능 손실: 아리바이오랩(-6,303) + 디앤디파마텍(-5,947) + 이후 5건
**약 +30,000~40,000원 손실 감소** (아주IB투자 TP1 기회 차단은 감수) **약 +20,000원 손실 감소** (아주IB투자/코스모로보틱스 수익 기회 차단 포함)
### 리스크 ### 리스크