fix(bat-052): CHG-20260626-02 보정 — buy_fee_only_assets 제거 + NFR-2 엄격화

portfolio-hub WAC가 매수 fee를 cost basis에 편입함에 따라(REQ-110 change-req)
이중계상을 방지하기 위해 buy_fee_only_assets 관련 로직을 전면 제거하고,
일중 닫힌 거래 AC-2 단언을 엄격 동치(realized_pnl_wac == realized_pnl)로 강화.

변경:
- OperatorReport.buy_fee_only_assets 필드 제거
- apply_wac_to_report buy_fee_only_assets 인자 제거
- buy_fee_by_asset 헬퍼 함수 제거
- render_text 매수전용 수수료 섹션 제거
- render_json buy_fee_only_assets 필드 제거 (WAC 필드 4개→3개)
- cli.py: buy_fee_by_asset import/사용 제거, 미사용 'from datetime import date, timedelta' 제거
- test_wac_equals_net_when_same_day_buy_sell: WAC 957.0, 엄격 동치 단언
- test_buy_only_assets_has_fee → test_buy_only_asset_no_fee_line (fee 라인 없음)
- test_render_json_has_all_four_wac_fields → test_render_json_has_three_wac_fields
- 동일 CLI 통합 테스트 보정

결과: 717 passed, 47 skipped

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHtM5Ws1HKCKQ4JGi6GRb5
This commit is contained in:
2026-06-26 20:35:17 +09:00
co-authored by Claude Sonnet 4.6
parent 73d3b35ab2
commit d3e4af59cf
4 changed files with 42 additions and 78 deletions
+14 -7
View File
@@ -143,8 +143,11 @@ class TestReportWacPath:
# 에러 없음
assert "unavailable" not in out
def test_wac_json_has_all_four_fields(self, capsys):
"""REQ-110 AC-6: --json에 4 WAC 필드 포함."""
def test_wac_json_has_three_wac_fields(self, capsys):
"""REQ-110 AC-6: --json에 3 WAC 필드 포함 (CHG-20260626-02: buy_fee_only_assets 제거).
필드: realized_pnl_wac, realized_pnl_wac_by_asset, data_completeness_warning.
"""
db_rows = [
[("005930", "pf-1", 10, 70000.0)],
[],
@@ -168,8 +171,9 @@ class TestReportWacPath:
assert rc == 0
j = json.loads(capsys.readouterr().out)
for field in ("realized_pnl_wac", "realized_pnl_wac_by_asset",
"buy_fee_only_assets", "data_completeness_warning"):
"data_completeness_warning"):
assert field in j, f"missing field: {field}"
assert "buy_fee_only_assets" not in j
def test_completeness_warning_in_text_and_json(self, capsys):
"""REQ-110 AC-4: completeness:true → text·json 경고 표면화."""
@@ -266,8 +270,11 @@ class TestReportWacPath:
assert j["fills_count"] == 1
assert j["holdings"][0]["symbol"] == "005930"
def test_buy_only_asset_fee_displayed(self, capsys):
"""REQ-110 AC-3: 매수만 → 실현 0 + buy_fee_only_assets 표시."""
def test_buy_only_asset_no_fee_line(self, capsys):
"""REQ-110 AC-3(변경): 매수만 → 실현 0, 별도 수수료 라인 없음.
CHG-20260626-02: 매수 fee 편입 → 매수 전용 자산 수수료 섹션 제거.
"""
db_rows = [
[("000660", "pf-2", 5, 50000.0)], # holdings (보유 중)
[],
@@ -291,8 +298,8 @@ class TestReportWacPath:
rc = cli.main(["report"])
assert rc == 0
out = capsys.readouterr().out
assert "매수 전용 자산 수수료" in out
assert "pf-2" in out
# 매수 전용 수수료 섹션은 더 이상 표시하지 않음
assert "매수 전용 자산 수수료" not in out
def test_no_fallback_to_daily_net(self, capsys):
"""REQ-111 AC-3: degrade 시 당일 net 폴백 안 함.