strategy: align model exit signal as assist-only trigger (#369)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
Doc-ID: DOC-REQ-001
|
Doc-ID: DOC-REQ-001
|
||||||
Version: 1.0.8
|
Version: 1.0.9
|
||||||
Status: active
|
Status: active
|
||||||
Owner: strategy
|
Owner: strategy
|
||||||
Updated: 2026-03-02
|
Updated: 2026-03-02
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Updated: 2026-03-02
|
|||||||
# v2/v3 구현 감사 및 수익률 분석 보고서
|
# v2/v3 구현 감사 및 수익률 분석 보고서
|
||||||
|
|
||||||
작성일: 2026-02-28
|
작성일: 2026-02-28
|
||||||
최종 업데이트: 2026-03-02 (#373 상태표 정합화 반영)
|
최종 업데이트: 2026-03-02 (#369 model 보조 트리거 사양 정합화 반영)
|
||||||
대상 기간: 2026-02-25 ~ 2026-02-28 (실거래)
|
대상 기간: 2026-02-25 ~ 2026-02-28 (실거래)
|
||||||
분석 브랜치: `feature/v3-session-policy-stream`
|
분석 브랜치: `feature/v3-session-policy-stream`
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ Updated: 2026-03-02
|
|||||||
| REQ-V2-001 | 4-상태 매도 상태기계 (HOLDING→BE_LOCK→ARMED→EXITED) | `src/strategy/position_state_machine.py` | ✅ 완료 |
|
| REQ-V2-001 | 4-상태 매도 상태기계 (HOLDING→BE_LOCK→ARMED→EXITED) | `src/strategy/position_state_machine.py` | ✅ 완료 |
|
||||||
| REQ-V2-002 | 즉시 최상위 상태 승격 (갭 대응) | `position_state_machine.py:51-70` | ✅ 완료 |
|
| REQ-V2-002 | 즉시 최상위 상태 승격 (갭 대응) | `position_state_machine.py:51-70` | ✅ 완료 |
|
||||||
| REQ-V2-003 | EXITED 우선 평가 | `position_state_machine.py:38-48` | ✅ 완료 |
|
| REQ-V2-003 | EXITED 우선 평가 | `position_state_machine.py:38-48` | ✅ 완료 |
|
||||||
| REQ-V2-004 | 4중 청산 로직 (Hard/BE/ATR Trailing/Model) | `src/strategy/exit_rules.py` | ⚠️ 부분 (`#369`) |
|
| REQ-V2-004 | 4중 청산 로직 (Hard/BE/ATR Trailing/Model) | `src/strategy/exit_rules.py` | ✅ 완료 |
|
||||||
| REQ-V2-005 | Triple Barrier 라벨링 | `src/analysis/triple_barrier.py` | ✅ 완료 |
|
| REQ-V2-005 | Triple Barrier 라벨링 | `src/analysis/triple_barrier.py` | ✅ 완료 |
|
||||||
| REQ-V2-006 | Walk-Forward + Purge/Embargo 검증 | `src/analysis/walk_forward_split.py` | ✅ 완료 |
|
| REQ-V2-006 | Walk-Forward + Purge/Embargo 검증 | `src/analysis/walk_forward_split.py` | ✅ 완료 |
|
||||||
| REQ-V2-007 | 비용/슬리피지/체결실패 모델 필수 | `src/analysis/backtest_cost_guard.py`, `src/analysis/backtest_pipeline.py` | ✅ 완료 |
|
| REQ-V2-007 | 비용/슬리피지/체결실패 모델 필수 | `src/analysis/backtest_cost_guard.py`, `src/analysis/backtest_pipeline.py` | ✅ 완료 |
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ def evaluate_exit(
|
|||||||
reason = "atr_trailing_stop"
|
reason = "atr_trailing_stop"
|
||||||
elif be_lock_threat:
|
elif be_lock_threat:
|
||||||
reason = "be_lock_threat"
|
reason = "be_lock_threat"
|
||||||
elif model_exit_signal:
|
|
||||||
reason = "model_liquidity_exit"
|
|
||||||
elif take_profit_hit:
|
elif take_profit_hit:
|
||||||
# Backward-compatible immediate profit-taking path.
|
# Backward-compatible immediate profit-taking path.
|
||||||
reason = "arm_take_profit"
|
reason = "arm_take_profit"
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ def evaluate_exit_first(inp: StateTransitionInput) -> bool:
|
|||||||
|
|
||||||
EXITED must be evaluated before any promotion.
|
EXITED must be evaluated before any promotion.
|
||||||
"""
|
"""
|
||||||
return inp.hard_stop_hit or inp.trailing_stop_hit or inp.model_exit_signal or inp.be_lock_threat
|
# model_exit_signal is assist-only and must not trigger EXIT directly.
|
||||||
|
return inp.hard_stop_hit or inp.trailing_stop_hit or inp.be_lock_threat
|
||||||
|
|
||||||
|
|
||||||
def promote_state(current: PositionState, inp: StateTransitionInput) -> PositionState:
|
def promote_state(current: PositionState, inp: StateTransitionInput) -> PositionState:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def test_take_profit_exit_for_backward_compatibility() -> None:
|
|||||||
assert out.reason == "arm_take_profit"
|
assert out.reason == "arm_take_profit"
|
||||||
|
|
||||||
|
|
||||||
def test_model_assist_exit_signal() -> None:
|
def test_model_assist_signal_does_not_exit_directly() -> None:
|
||||||
out = evaluate_exit(
|
out = evaluate_exit(
|
||||||
current_state=PositionState.ARMED,
|
current_state=PositionState.ARMED,
|
||||||
config=ExitRuleConfig(model_prob_threshold=0.62, arm_pct=10.0),
|
config=ExitRuleConfig(model_prob_threshold=0.62, arm_pct=10.0),
|
||||||
@@ -34,5 +34,5 @@ def test_model_assist_exit_signal() -> None:
|
|||||||
liquidity_weak=True,
|
liquidity_weak=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert out.should_exit is True
|
assert out.should_exit is False
|
||||||
assert out.reason == "model_liquidity_exit"
|
assert out.reason == "hold"
|
||||||
|
|||||||
@@ -28,3 +28,16 @@ def test_exited_has_priority_over_promotion() -> None:
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert state == PositionState.EXITED
|
assert state == PositionState.EXITED
|
||||||
|
|
||||||
|
|
||||||
|
def test_model_signal_is_assist_only_not_direct_exit() -> None:
|
||||||
|
state = promote_state(
|
||||||
|
PositionState.ARMED,
|
||||||
|
StateTransitionInput(
|
||||||
|
unrealized_pnl_pct=1.0,
|
||||||
|
be_arm_pct=1.2,
|
||||||
|
arm_pct=2.8,
|
||||||
|
model_exit_signal=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assert state == PositionState.ARMED
|
||||||
|
|||||||
@@ -105,3 +105,19 @@
|
|||||||
- next_ticket: #368
|
- next_ticket: #368
|
||||||
- process_gate_checked: process_ticket=#306,#308 merged_to_feature_branch=yes
|
- process_gate_checked: process_ticket=#306,#308 merged_to_feature_branch=yes
|
||||||
- risks_or_notes: TASK-V2-012 구현 갭 보완을 위해 cost guard + execution-adjusted fold metric + 회귀 테스트를 함께 반영한다.
|
- risks_or_notes: TASK-V2-012 구현 갭 보완을 위해 cost guard + execution-adjusted fold metric + 회귀 테스트를 함께 반영한다.
|
||||||
|
|
||||||
|
### 2026-03-02 | session=codex-v3-stream-next-ticket-369
|
||||||
|
- branch: feature/v3-session-policy-stream
|
||||||
|
- docs_checked: docs/workflow.md, docs/commands.md, docs/agent-constraints.md
|
||||||
|
- open_issues_reviewed: #369, #370, #371, #374, #375, #376, #377, #381
|
||||||
|
- next_ticket: #369
|
||||||
|
- process_gate_checked: process_ticket=#306,#308 merged_to_feature_branch=yes
|
||||||
|
- risks_or_notes: 구현 티켓은 코드/테스트/문서(요구사항 원장/구현감사/PR traceability) 동시 반영을 기본 원칙으로 진행한다.
|
||||||
|
|
||||||
|
### 2026-03-02 | session=codex-issue369-start
|
||||||
|
- branch: feature/issue-369-model-exit-signal-spec-sync
|
||||||
|
- docs_checked: docs/workflow.md, docs/commands.md, docs/agent-constraints.md
|
||||||
|
- open_issues_reviewed: #369
|
||||||
|
- next_ticket: #369
|
||||||
|
- process_gate_checked: process_ticket=#306,#308 merged_to_feature_branch=yes
|
||||||
|
- risks_or_notes: v2 사양 기준으로 model_exit_signal을 직접 청산 트리거가 아닌 보조 트리거로 정합화하고 테스트/문서를 동기화한다.
|
||||||
|
|||||||
Reference in New Issue
Block a user