fix: enforce take_profit_pct in HOLD evaluation loop (#163) #166

Merged
jihoson merged 1 commits from feature/issue-163-take-profit-enforcement into main 2026-02-20 07:24:15 +09:00
Collaborator

Summary

  • main.py HOLD 평가 블록에 take_profit_pct 익절 조건 체크 추가
  • AI가 생성한 take_profit_pct가 실제 거래 로직에서 완전히 무시되던 버그 수정
  • stop_loss와 상호 배타적으로 동작 (stop_loss 먼저 체크)

변경 내용

# Before: stop_loss만 체크
if loss_pct <= stop_loss_threshold:
    decision = TradeDecision(action="SELL", ...)

# After: take_profit도 체크
if loss_pct <= stop_loss_threshold:
    decision = TradeDecision(action="SELL", confidence=95, ...)
elif loss_pct >= take_profit_threshold:
    decision = TradeDecision(action="SELL", confidence=90, ...)

Test plan

  • test_hold_overridden_to_sell_when_take_profit_triggered — +6% 수익 시 SELL 전환
  • test_hold_not_overridden_when_between_stop_loss_and_take_profit — +1% 수익 시 HOLD 유지
  • test_hold_overridden_to_sell_when_stop_loss_triggered — 기존 stop_loss 동작 유지 확인
  • 672 tests passed

Closes #163

🤖 Generated with Claude Code

## Summary - `main.py` HOLD 평가 블록에 `take_profit_pct` 익절 조건 체크 추가 - AI가 생성한 `take_profit_pct`가 실제 거래 로직에서 완전히 무시되던 버그 수정 - `stop_loss`와 상호 배타적으로 동작 (stop_loss 먼저 체크) ## 변경 내용 ```python # Before: stop_loss만 체크 if loss_pct <= stop_loss_threshold: decision = TradeDecision(action="SELL", ...) # After: take_profit도 체크 if loss_pct <= stop_loss_threshold: decision = TradeDecision(action="SELL", confidence=95, ...) elif loss_pct >= take_profit_threshold: decision = TradeDecision(action="SELL", confidence=90, ...) ``` ## Test plan - [x] `test_hold_overridden_to_sell_when_take_profit_triggered` — +6% 수익 시 SELL 전환 - [x] `test_hold_not_overridden_when_between_stop_loss_and_take_profit` — +1% 수익 시 HOLD 유지 - [x] `test_hold_overridden_to_sell_when_stop_loss_triggered` — 기존 stop_loss 동작 유지 확인 - [x] 672 tests passed Closes #163 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-20 03:01:10 +09:00
fix: enforce take_profit_pct in HOLD evaluation loop (#163)
Some checks failed
CI / test (pull_request) Has been cancelled
5844ec5ad3
HOLD 판정 후 보유 포지션에 대해 stop_loss와 함께 take_profit도 체크하도록 수정.
AI가 생성한 take_profit_pct가 실제 거래 로직에 반영되지 않던 구조적 결함 수정.

- HOLD 블록에서 loss_pct >= take_profit_threshold 조건 추가
- stop_loss와 상호 배타적으로 동작 (stop_loss 우선 체크)
- take_profit 기본값 3.0% (playbook 없는 경우 적용)
- 테스트 2개 추가:
  - test_hold_overridden_to_sell_when_take_profit_triggered
  - test_hold_not_overridden_when_between_stop_loss_and_take_profit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jihoson merged commit faa23b3f1b into main 2026-02-20 07:24:15 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#166