Files
portfolio-hub/docs/batches/bat-018_20260625_holdings-cost-basis-endpoint/index.md
T
genichinandClaude Sonnet 4.6 bd8ff1bf45 docs(gov): BAT-018/REQ-043 거버넌스 마감 — Implemented + release-candidate 전환
- REQ-043: Approved → Implemented (BAT-018 PR #14 squash d93c0bc, 팀장 QC PASS, origin/main 머지)
- BAT-018: in-progress → release-candidate (배포 별도 — 미배포)
- dcy-008 생성된 REQ 참조에 Implemented 반영
- srs/index.md Requirement Register 및 Recent Change Log Summary 갱신 (최신 5건)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHtM5Ws1HKCKQ4JGi6GRb5
2026-06-26 15:52:44 +09:00

37 lines
2.2 KiB
Markdown

# BAT-018: 현재 보유 평단(WAC) 조회 엔드포인트 신설 (REQ-043)
- Status: release-candidate
- Profile: batch-lite
- Source Discovery: dcy-008 (현재 보유 종목별 평단(WAC) 조회 API)
- Included REQ: REQ-043
- Excluded REQ: none
## Summary
- `GET /v1/portfolios/{portfolio_id}/holdings/cost-basis` 신규 엔드포인트 신설.
- 현재 미매도 보유 종목의 (symbol, current_quantity, cost_basis_per_unit=WAC, total_cost_basis, cost_basis_from, data_completeness_warning) 반환.
- WAC 산출은 `app/domain/pnl.py`의 기존 running_wac 로직(REQ-041)을 재사용하는 `calculate_current_wac` 신규 함수로 분리(단일책임 원칙).
- 인증: `require_read` + service token(daemon scope) 소유권 정책(REQ-029 선례, `daemon_id == managed_by_daemon_id` 일치).
- trex-core dcy-034 FR-7(cold-start 슬롯 평단 seed)의 선행 의존.
## Scope
- In Scope:
- `app/domain/pnl.py` — `calculate_current_wac` 신규 함수 추가 (running_wac 로직 재사용)
- `app/schemas/v1.py` — `HoldingsCostBasisResponse` 스키마 신규 추가
- `app/api/v1_portfolios.py` — `GET /holdings/cost-basis` 엔드포인트 추가 (service/user token 소유권 분기)
- `tests/test_v1_portfolios_holdings.py` — AC-1~11 커버 신규 테스트 파일
- `docs/batches/index.md` — BAT-018 register 행 추가
- Out of Scope:
- 미실현 손익(현재가 결합) — portfolio-hub 시세 비소유
- DB 스키마 변경/마이그레이션 — 기존 portfolio_ledger 재사용
- repository 신규 메서드 — `get_all_trades_for_pnl` 재사용(신규 SQL 불필요)
## Documents
- Planning: [planning.md](./planning.md)
- Design: none (batch-lite, design gate skip)
- Implementation: [implementation.md](./implementation.md)
- Verification: [verification.md](./verification.md)
## Notes
- profile 선정 근거: 단일 Approved REQ(REQ-043) + read-only(쓰기·마이그레이션 없음) + 기존 WAC 로직/인증 패턴 재사용 → batch-lite 적합.
- design 생략 근거: 신규 엔드포인트이나 기존 `get_realized_pnl` 패턴을 그대로 따르고, WAC 함수는 기존 `calculate_realized_pnl` running_wac 추출로 구현 결정이 단순함.