Files
trex-core/docs/batches/bat-014_20260608_safety-sell-cooldown/planning.md
T
genichinandClaude Opus 4.8 565af6792c feat(safety-sell): dcy-010 BAT-014 — 영속 거부 재시도 쿨다운 (REQ-052~054)
dcy-010(safety-sell 영속 거부 재시도 백오프) 전체 SDLC: draft-req → confirm-req →
draft-batch(BAT-014 batch-lite) → run-batch-delivery → confirm-req-implemented.
2026-06-07 실 KIS LIVE SL/TP e2e에서 발견한 KIS 주문 spam 위험(영속 거부 시
매도 무한 재제출) 차단.

- REQ-052 (Integration): SafetySellService per-slot 인메모리 쿨다운
  (_in_cooldown/_attempt_sell/_prune_cooldown) — forced_close·stop-loss·take-profit
  트리거에 min_retry_interval_sec(600s) 이내 재시도 skip(가격 poll 포함) +
  max_retry_warn_count(3) 도달 시 WARNING + holding 이탈 정리. market_close 제외.
- REQ-053 (Configuration): SafetySellConfig min_retry_interval_sec/max_retry_warn_count
  + TREX_SAFETY_SELL_MIN_RETRY_INTERVAL/MAX_RETRY_WARN_COUNT env (additive)
- REQ-054 (Documentation): runtime-flows 쿨다운 flow + 가격체크 tr_id(FHKST01010100) 정정

인메모리 only(DB/스레드/인터페이스 변경 없음), default 미설정 시 기존 동작 불변.
검증: 신규 8 단위(쿨다운 6 + config 2), 전체 278 passed, ruff clean.
REQ-052~054 Implemented, BAT-014 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 00:35:11 +09:00

2.4 KiB

BAT-014 Planning

  • Status: confirmed
  • Batch: BAT-014
  • Profile: batch-lite

Included REQ

  • REQ-052 (Integration): SafetySellService per-slot 쿨다운(_last_attempt/_attempt_count) + _safe_sell 전 skip / 만료 재시도 + 경고 로그 + holding 이탈 정리. market_close 제외.
  • REQ-053 (Configuration): SafetySellConfig.min_retry_interval_sec(env TREX_SAFETY_SELL_MIN_RETRY_INTERVAL, 기본 600) + max_retry_warn_count(env TREX_SAFETY_SELL_MAX_RETRY_WARN_COUNT, 기본 3).
  • REQ-054 (Documentation): docs/runtime-flows.md safety-sell tick 쿨다운 단계.

Delivery Plan

  1. REQ-053: SafetySellConfig 필드 2종 + from_env 파싱 → test_safety_sell_config.py 기본값/파싱.
  2. REQ-052: SafetySellService.__init__ dict 2종 + check_forced_close/check_prices 쿨다운 gate(skip/update) + attempt_count 경고 + run_once holding 이탈 정리. SafetySellService 가 config 의 두 값을 사용. paper reject_symbols 시뮬 단위 테스트(skip/만료 재시도/경고/정리/market_close 제외/트리거 해소).
  3. REQ-054: runtime-flows 갱신.
  4. 전체 회귀 + ruff.

Dependencies

  • Internal: dcy-007/BAT-011 SafetySellService(변경 대상) + SafetySellConfig(REQ-041). paper reject_symbols(REQ-011/BAT-009) — 거부 시뮬.
  • External: 없음.

Design Gate

  • Design Required Before Implementation: no
  • Reason: 변경이 단일 service 인메모리 dict 추가 + config 2 필드 + 문서로 국소적이고, 구조/인터페이스/DB/스레드 영향이 없다(추가 스레드·스키마 없음, 단일 스레드 호출이라 무락). 쿨다운 알고리즘·기본값·트리거 적용 범위가 dcy-010 §4/§6(OQ-1/2/3 Answered)에 완비되어 설계 모호성이 없다 → batch-lite, design.md 생략.

Milestones

  1. M1 — REQ-053 config 2종 + 단위 green
  2. M2 — REQ-052 쿨다운 로직 + paper reject 시뮬 단위 green
  3. M3 — REQ-054 runtime-flows
  4. M4 — 전체 회귀 + ruff

Risks

  • R-1 (Low): 쿨다운 중 트리거 해소 시 불필요 경고 — holding 이탈 정리(FR-4) + 조건 해소 시 _safe_sell 미호출로 완화.
  • R-2 (Low): 재시작 시 쿨다운 초기화 → 1회 즉시 재시도 — 허용(문서 주의).
  • R-3 (Low): paper 기본은 거부 안 함 → reject_symbols 시뮬로 테스트 커버.

Notes

  • batch-lite: design 생략(Design Gate no). implementation.md/verification.md 는 구현/검증 stage 진입 시 생성.