fix(workspaces): seed new defaults from live quote

This commit is contained in:
Bu5hm4nn
2026-03-25 19:48:58 +01:00
parent 782e8f692e
commit aae67dfd9b
5 changed files with 77 additions and 17 deletions

View File

@@ -16,6 +16,17 @@ _DEFAULT_GOLD_OUNCES = 100.0
_LEGACY_DEFAULT_GOLD_OUNCES = 1_000.0
def build_default_portfolio_config(*, entry_price: float | None = None) -> "PortfolioConfig":
resolved_entry_price = float(entry_price) if entry_price is not None else _DEFAULT_ENTRY_PRICE
gold_value = resolved_entry_price * _DEFAULT_GOLD_OUNCES
return PortfolioConfig(
gold_value=gold_value,
entry_price=resolved_entry_price,
gold_ounces=_DEFAULT_GOLD_OUNCES,
entry_basis_mode="value_price",
)
@dataclass(frozen=True)
class LombardPortfolio:
"""Lombard loan portfolio backed by physical gold."""
@@ -122,8 +133,9 @@ class PortfolioConfig:
raise ValueError("Gold weight must be positive")
if self.gold_value is None and self.gold_ounces is None:
self.gold_value = _DEFAULT_GOLD_VALUE
self.gold_ounces = self.gold_value / self.entry_price
default = build_default_portfolio_config(entry_price=self.entry_price)
self.gold_value = default.gold_value
self.gold_ounces = default.gold_ounces
return
if self.gold_value is None and self.gold_ounces is not None: