fix: SELL outcome PnL uses sell quantity (#322) #337
Reference in New Issue
Block a user
Delete Branch "feature/issue-322-sell-pnl-sell-qty"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Validation
Ticket Maturity Update (2026-02-28)
Coverage Matrix:
Review: PR #337 — fix: SELL outcome PnL uses sell quantity (#322)
플랜 일치: ✅ ACT-05 정확히 일치
trade_pnl = (trade_price - buy_price) * sell_qty로 변경코드 품질: ✅ 정확
sell_qty = int(quantity or 0)— quantity가 None인 경우 0으로 폴백테스트: ⚠️ 부족
우려사항
int(quantity or 0)— quantity가 None일 때sell_qty=0이 되어 PnL이 항상 0이 됨. 이 경우 buy_qty 폴백이 더 안전할 수 있음. 명시적 방어 로직 또는 경고 로그 권장.결론: Changes Requested — 부분 매도 테스트 추가 + quantity=None 케이스 방어 로직 필요
리뷰 반영 완료했습니다.
변경 사항:
sell_qty가 비정상(None/0)일 때buy_qty폴백_resolve_sell_qty_for_pnl()헬퍼 추가로 수량 기준 로직을 명시화test_sell_order_uses_broker_balance_qty_not_db/test_sell_updates_original_buy_decision_outcome유지검증:
pytest -q tests/test_main.py -k "resolve_sell_qty_for_pnl or sell_order_uses_broker_balance_qty_not_db or sell_updates_original_buy_decision_outcome"Re-review: PR #337 — fix: SELL outcome PnL uses sell quantity (#322)
이전 리뷰 지적사항 반영 확인
quantity=None 방어 로직: ✅ 해결
_resolve_sell_qty_for_pnl()헬퍼 함수 추가int(quantity or 0)의 무조건 0 문제 해결됨부분 매도 전용 테스트: ✅ 추가됨
test_resolve_sell_qty_for_pnl_prefers_sell_qty(sell_qty=30, buy_qty=100 → 30)test_resolve_sell_qty_for_pnl_uses_buy_qty_fallback_when_sell_qty_missing(None → buy_qty 폴백)test_resolve_sell_qty_for_pnl_returns_zero_when_both_missing(둘 다 None → 0)기존 테스트 PnL 검증: ✅ 유지
test_sell_order_uses_broker_balance_qty_not_db에 outcome_pnl 검증 추가코드 품질
결론: LGTM ✅