feat(CORE-002B): roll out hedge quote unit conversion

This commit is contained in:
Bu5hm4nn
2026-03-25 15:46:44 +01:00
parent f00b58bba0
commit 829c0b5da2
7 changed files with 223 additions and 30 deletions

View File

@@ -82,7 +82,11 @@ def resolve_portfolio_spot_from_quote(
return _decimal_to_float(converted_spot.amount), quote_source, quote_updated_at
def portfolio_snapshot_from_config(config: PortfolioConfig | None = None) -> dict[str, float]:
def portfolio_snapshot_from_config(
config: PortfolioConfig | None = None,
*,
runtime_spot_price: float | None = None,
) -> dict[str, float]:
if config is None:
gold_weight = Weight(amount=Decimal("1000"), unit=WeightUnit.OUNCE_TROY)
spot = PricePerWeight(amount=Decimal("215"), currency=BaseCurrency.USD, per_unit=WeightUnit.OUNCE_TROY)
@@ -91,7 +95,8 @@ def portfolio_snapshot_from_config(config: PortfolioConfig | None = None) -> dic
hedge_budget = Money(amount=Decimal("8000"), currency=BaseCurrency.USD)
else:
gold_weight = _gold_weight(float(config.gold_ounces or 0.0))
spot = _spot_price(float(config.entry_price or 0.0))
resolved_spot = runtime_spot_price if runtime_spot_price is not None else float(config.entry_price or 0.0)
spot = _spot_price(resolved_spot)
loan_amount = Money(amount=decimal_from_float(float(config.loan_amount)), currency=BaseCurrency.USD)
margin_call_ltv = decimal_from_float(float(config.margin_threshold))
hedge_budget = Money(amount=decimal_from_float(float(config.monthly_budget)), currency=BaseCurrency.USD)