feat(CORE-002B): roll out hedge quote unit conversion
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user