feat(PORTFOLIO-002): add position storage costs
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.responses import RedirectResponse
|
||||
@@ -21,6 +22,7 @@ from app.pages.common import (
|
||||
from app.services.alerts import AlertService, build_portfolio_alert_context
|
||||
from app.services.ltv_history import LtvHistoryChartModel, LtvHistoryService
|
||||
from app.services.runtime import get_data_service
|
||||
from app.services.storage_costs import calculate_total_storage_cost
|
||||
from app.services.turnstile import load_turnstile_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -163,6 +165,17 @@ async def overview_page(workspace_id: str) -> None:
|
||||
configured_gold_value = float(config.gold_value or 0.0)
|
||||
portfolio["cash_buffer"] = max(float(portfolio["gold_value"]) - configured_gold_value, 0.0) + _DEFAULT_CASH_BUFFER
|
||||
portfolio["hedge_budget"] = float(config.monthly_budget)
|
||||
|
||||
# Calculate storage costs for positions
|
||||
positions = config.positions
|
||||
current_values: dict[str, Decimal] = {}
|
||||
for pos in positions:
|
||||
# Use entry value as proxy for current value (would need live prices for accurate calc)
|
||||
current_values[str(pos.id)] = pos.entry_value
|
||||
total_annual_storage_cost = calculate_total_storage_cost(positions, current_values)
|
||||
portfolio["annual_storage_cost"] = float(total_annual_storage_cost)
|
||||
portfolio["storage_cost_pct"] = (float(total_annual_storage_cost) / float(portfolio["gold_value"]) * 100) if portfolio["gold_value"] > 0 else 0.0
|
||||
|
||||
alert_status = AlertService().evaluate(config, portfolio)
|
||||
ltv_history_service = LtvHistoryService(repository=LtvHistoryRepository(base_path=repo.base_path))
|
||||
ltv_history_notice: str | None = None
|
||||
@@ -362,6 +375,11 @@ async def overview_page(workspace_id: str) -> None:
|
||||
f"${portfolio['hedge_budget']:,.0f}",
|
||||
"Monthly budget from saved settings",
|
||||
),
|
||||
(
|
||||
"Storage Costs",
|
||||
f"${portfolio['annual_storage_cost']:,.2f}/yr ({portfolio['storage_cost_pct']:.2f}%)",
|
||||
"Annual vault storage for physical positions (GLD expense ratio baked into share price)",
|
||||
),
|
||||
]
|
||||
for title, value, caption in summary_cards:
|
||||
with ui.card().classes(
|
||||
|
||||
Reference in New Issue
Block a user