refactor: CB 게이지 pnl_pct 저장 레이어를 L7 → L6_DAILY로 변경
Some checks failed
CI / test (pull_request) Has been cancelled

portfolio_pnl_pct는 일별 성과 지표이므로 실시간 종목 데이터(L7)보다
일별 P&L 레이어(L6_DAILY)가 더 적합함. (PR #197 코드리뷰 반영)

- main.py: L7_REALTIME + ISO timestamp → L6_DAILY + date(YYYY-MM-DD)
- app.py: contexts 쿼리 layer/timeframe 조건 동기화
- tests: _seed_cb_context L6_DAILY + today 날짜로 수정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
agentson
2026-02-22 00:33:21 +09:00
parent 342511a6ed
commit f3491e94e4
3 changed files with 13 additions and 9 deletions

View File

@@ -85,11 +85,13 @@ def create_dashboard_app(db_path: str) -> FastAPI:
"""
SELECT key, value
FROM contexts
WHERE layer = 'L7_REALTIME'
WHERE layer = 'L6_DAILY'
AND timeframe = ?
AND key LIKE 'portfolio_pnl_pct_%'
ORDER BY updated_at DESC
LIMIT 20
"""
""",
(today,),
).fetchall()
current_pnl_pct: float | None = None
if pnl_pct_rows:

View File

@@ -430,10 +430,10 @@ async def trading_cycle(
{"volume_ratio": candidate.volume_ratio},
)
# Store latest pnl_pct in L7 so the dashboard can display the CB gauge
# Store latest pnl_pct in L6 (daily P&L layer) so the dashboard can display the CB gauge
context_store.set_context(
ContextLayer.L7_REALTIME,
timeframe,
ContextLayer.L6_DAILY,
datetime.now(UTC).date().isoformat(),
f"portfolio_pnl_pct_{market.code}",
{"pnl_pct": round(pnl_pct, 4)},
)