feat: add position-aware conditions to StockCondition (#171) #175

Merged
jihoson merged 1 commits from feature/issue-171-position-aware-conditions into main 2026-02-20 08:36:07 +09:00
Collaborator

Summary

  • StockCondition에 포지션 인식 조건 필드 4개 추가: unrealized_pnl_pct_above/below, holding_days_above/below
  • ScenarioEngine.evaluate_condition()에서 새 필드를 기존 AND 결합 로직으로 평가
  • _build_match_details()에 포지션 필드 포함 (감사 로그용)
  • PreMarketPlanner._parse_scenario()에서 AI JSON 응답의 새 필드 파싱
  • 프롬프트 스키마 예시에 포지션 인식 조건 필드 추가

Test plan

  • test_evaluate_condition_unrealized_pnl_above_matches
  • test_evaluate_condition_unrealized_pnl_above_no_match
  • test_evaluate_condition_unrealized_pnl_below_matches
  • test_evaluate_condition_unrealized_pnl_below_no_match
  • test_evaluate_condition_holding_days_above_matches
  • test_evaluate_condition_holding_days_above_no_match
  • test_evaluate_condition_holding_days_below_matches
  • test_evaluate_condition_holding_days_below_no_match
  • test_combined_pnl_and_holding_days
  • test_missing_unrealized_pnl_does_not_match
  • test_missing_holding_days_does_not_match
  • test_match_details_includes_position_fields
  • test_position_conditions_parse_from_planner
  • 기존 104개 테스트 전체 통과

Closes #171

🤖 Generated with Claude Code

## Summary - StockCondition에 포지션 인식 조건 필드 4개 추가: unrealized_pnl_pct_above/below, holding_days_above/below - ScenarioEngine.evaluate_condition()에서 새 필드를 기존 AND 결합 로직으로 평가 - _build_match_details()에 포지션 필드 포함 (감사 로그용) - PreMarketPlanner._parse_scenario()에서 AI JSON 응답의 새 필드 파싱 - 프롬프트 스키마 예시에 포지션 인식 조건 필드 추가 ## Test plan - [x] test_evaluate_condition_unrealized_pnl_above_matches - [x] test_evaluate_condition_unrealized_pnl_above_no_match - [x] test_evaluate_condition_unrealized_pnl_below_matches - [x] test_evaluate_condition_unrealized_pnl_below_no_match - [x] test_evaluate_condition_holding_days_above_matches - [x] test_evaluate_condition_holding_days_above_no_match - [x] test_evaluate_condition_holding_days_below_matches - [x] test_evaluate_condition_holding_days_below_no_match - [x] test_combined_pnl_and_holding_days - [x] test_missing_unrealized_pnl_does_not_match - [x] test_missing_holding_days_does_not_match - [x] test_match_details_includes_position_fields - [x] test_position_conditions_parse_from_planner - [x] 기존 104개 테스트 전체 통과 Closes #171 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-20 08:27:54 +09:00
feat: add position-aware conditions to StockCondition (#171)
Some checks failed
CI / test (pull_request) Has been cancelled
60a22d6cd4
- Add unrealized_pnl_pct_above/below and holding_days_above/below fields
  to StockCondition so AI can generate rules like 'P&L > 3% → SELL'
- Evaluate new fields in ScenarioEngine.evaluate_condition() with same
  AND-combining logic as existing technical indicator fields
- Include position fields in _build_match_details() for audit logging
- Parse new fields from AI JSON response in PreMarketPlanner._parse_scenario()
- Update prompt schema example to show new position-aware condition fields
- Add 13 tests covering all new condition combinations and edge cases

Closes #171

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jihoson merged commit a33d6a145f into main 2026-02-20 08:36:07 +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#175