Files
trex-core/docs/batches/bat-033_20260610_enter-qty-validation/implementation.md
T
genichinandClaude Sonnet 4.6 fb05a73130 feat(rel-006): dcy-022/023 + BAT-032~034 — 실행 정책·qty 검증·allocated_capital 제거 통합
BAT-032 (dcy-022): timeout_sec/slippage_pct 실행 정책, 미체결 자동 취소,
보호 지정가, `trex-core cancel` 백스톱. 마이그레이션 012.
BAT-033: `trex-core enter --qty` 필수 검증 — 미지정 시 RPC 전 즉시 오류.
BAT-034 (dcy-023): allocated_capital 죽은 필드 전 경로 제거 (domain·intent·
persistence·snapshot·CLI). 마이그레이션 013(비가역 DROP). 외부 발신자
unknown key 무시 수신 의미론 적용.
REL-006 confirmed: BAT-026~034 통합 릴리즈, pre-release smoke 증거 포함.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 07:42:03 +09:00

1.5 KiB

BAT-033 Implementation

  • Status: done
  • Batch: BAT-033

변경 파일

파일 변경 유형 연결 REQ/AC
trex_core/runtime/cli.py 수정 REQ-032 CHG-20260610-06 AC-7
tests/runtime/test_cli_operator.py 수정 AC-7 검증 + 기존 enter 테스트 --qty 보완

M1: enter --qty 미지정 검증

trex_core/runtime/cli.py

_cmd_enter 함수 상단(forced_close_at 검증 앞)에 qty 검증 블록 추가:

# REQ-032 AC-7 (CHG-20260610-06, issue #23): qty is required — reject before
# RPC so a missing --qty fails immediately instead of admitting a zero-qty order
# that the broker rejects silently after the fact.
if not args.qty:
    _fail("--qty is required for enter (no quantity → broker would reject)", args.json)
    return 1
  • --qty 없음(None) 또는 0 → 즉시 rc=1, RPC 미호출
  • --dry-run 경로도 동일하게 걸림 (qty 검증이 _intent_guard 진입 전에 위치)
  • 기존 --qty 있는 경우 동작 불변

tests/runtime/test_cli_operator.py

신규 테스트 (AC-7):

  • test_enter_without_qty_errors_before_rpc — --qty 없이 enter → rc=1, rpc.calls==[], stderr에 --qty 포함

기존 테스트 수정 (회귀 방지): 기존 enter 테스트 9개에 "--qty", "10" (또는 적절한 값) 추가. qty 검증이 가장 앞에 위치하므로, 각 테스트가 본래 의도한 guard(confirm abort, live guard, json guard, forced_close_at 검증 등)에 도달하도록 보정.