feat(cli): enter --forced-close-at 시간 기반 자동청산 옵션 (issue #17, BAT-024)
trex-core enter 에 --forced-close-at <ISO8601>(절대시간) 옵션 추가. 지정 시 buy intent payload 의 기존 forced_close_at 에 매핑(계약·도메인· forced-close 루프 REQ-037 불변, CLI 노출 갭만 보완). 잘못된 형식은 제출 전 거부, 미지정 시 미포함(하위호환). 상대시간 옵션은 미채택. REQ-032 change-req(CHG-20260609-01/02) → BAT-024(batch-lite) → Implemented. 단위 353 passed, ruff clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,32 @@ def test_enter_with_yes_submits_buy_intent():
|
||||
assert "symbol" not in p # server-resolved (dcy-011)
|
||||
|
||||
|
||||
def test_enter_with_forced_close_at_maps_to_payload():
|
||||
# REQ-032 AC-5: --forced-close-at (absolute) → buy intent forced_close_at.
|
||||
rpc = _RpcRecorder(_ADMITTED)
|
||||
rc = cli.main(["enter", "PF-1", "--capital", "100000", "--yes",
|
||||
"--forced-close-at", "2026-06-09T15:20:00+09:00"], rpc=rpc)
|
||||
assert rc == 0
|
||||
p = rpc.calls[0]["payload"]
|
||||
assert p["forced_close_at"] == "2026-06-09T15:20:00+09:00"
|
||||
|
||||
|
||||
def test_enter_without_forced_close_at_omits_field():
|
||||
# REQ-032 AC-6: unspecified → field absent (backward compat).
|
||||
rpc = _RpcRecorder(_ADMITTED)
|
||||
rc = cli.main(["enter", "PF-1", "--capital", "100000", "--yes"], rpc=rpc)
|
||||
assert rc == 0
|
||||
assert "forced_close_at" not in rpc.calls[0]["payload"]
|
||||
|
||||
|
||||
def test_enter_rejects_malformed_forced_close_at_before_submit():
|
||||
# REQ-032 AC-6: invalid timestamp rejected at CLI, no RPC submitted.
|
||||
rpc = _RpcRecorder(_ADMITTED)
|
||||
rc = cli.main(["enter", "PF-1", "--capital", "100000", "--yes",
|
||||
"--forced-close-at", "notatime"], rpc=rpc)
|
||||
assert rc == 1 and rpc.calls == []
|
||||
|
||||
|
||||
def test_enter_rejected_returns_nonzero():
|
||||
rpc = _RpcRecorder(_REJECTED)
|
||||
rc = cli.main(["enter", "PF-x", "--yes"], rpc=rpc)
|
||||
|
||||
Reference in New Issue
Block a user