feat(PRICING-003): use true GLD backing for hedge contract count

This commit is contained in:
Bu5hm4nn
2026-03-28 09:18:26 +01:00
parent 894d88f72f
commit 966cee7963
4 changed files with 176 additions and 20 deletions

View File

@@ -28,10 +28,11 @@ def test_protective_put_costs(
assert cost["label"] == "ATM"
assert cost["strike"] == 460.0
assert cost["premium_per_share"] == pytest.approx(19.6894, abs=1e-4)
assert cost["total_cost"] == pytest.approx(42803.14, abs=1e-2)
assert cost["cost_pct_of_portfolio"] == pytest.approx(0.042803, abs=1e-6)
assert cost["annualized_cost"] == pytest.approx(42803.14, abs=1e-2)
assert cost["annualized_cost_pct"] == pytest.approx(0.042803, abs=1e-6)
# Total cost uses corrected GLD backing (contract_count * contract_size * premium)
assert cost["total_cost"] == pytest.approx(42913.36, abs=1e-2)
assert cost["cost_pct_of_portfolio"] == pytest.approx(0.042913, abs=1e-6)
assert cost["annualized_cost"] == pytest.approx(42913.36, abs=1e-2)
assert cost["annualized_cost_pct"] == pytest.approx(0.042913, abs=1e-6)
def test_laddered_strategy(sample_strategy_config: StrategyConfig, monkeypatch: pytest.MonkeyPatch) -> None:
@@ -53,12 +54,14 @@ def test_laddered_strategy(sample_strategy_config: StrategyConfig, monkeypatch:
assert cost["legs"][0]["weight"] == 0.5
assert cost["legs"][0]["strike"] == 460.0
assert cost["legs"][1]["strike"] == 437.0
assert cost["blended_cost"] == pytest.approx(34200.72, abs=1e-2)
assert cost["cost_pct_of_portfolio"] == pytest.approx(0.034201, abs=1e-6)
# Costs updated to reflect corrected GLD backing
assert cost["blended_cost"] == pytest.approx(34288.79, abs=1e-2)
assert cost["cost_pct_of_portfolio"] == pytest.approx(0.034289, abs=1e-6)
assert protection["portfolio_floor_value"] == pytest.approx(975000.0, rel=1e-12)
assert protection["payoff_at_threshold"] == pytest.approx(175000.0, abs=1e-2)
assert protection["hedged_ltv_at_threshold"] == pytest.approx(0.615385, rel=1e-6)
# Floor value uses notional_units (corrected backing)
assert protection["portfolio_floor_value"] == pytest.approx(977510.63, rel=1e-6)
assert protection["payoff_at_threshold"] == pytest.approx(175450.63, abs=1e-2)
assert protection["hedged_ltv_at_threshold"] == pytest.approx(0.615100, rel=1e-6)
assert protection["maintains_margin_call_buffer"] is True
@@ -90,16 +93,17 @@ def test_scenario_analysis(
first_protective = protective_scenarios[0]
assert first_protective["price_change_pct"] == -0.6
assert first_protective["gld_price"] == 184.0
assert first_protective["option_payoff"] == pytest.approx(600000.0, abs=1e-2)
assert first_protective["hedge_cost"] == pytest.approx(42803.14, abs=1e-2)
assert first_protective["hedged_ltv"] == pytest.approx(0.6, rel=1e-12)
# Option payoff uses corrected contract count and notional
assert first_protective["option_payoff"] == pytest.approx(601545.00, abs=1e-2)
assert first_protective["hedge_cost"] == pytest.approx(42913.36, abs=1e-2)
assert first_protective["hedged_ltv"] == pytest.approx(0.599074, rel=1e-6)
assert first_protective["margin_call_with_hedge"] is False
first_ladder = ladder_scenarios[0]
assert first_ladder["gld_price"] == 184.0
assert first_ladder["option_payoff"] == pytest.approx(575000.0, abs=1e-2)
assert first_ladder["hedge_cost"] == pytest.approx(34200.72, abs=1e-2)
assert first_ladder["hedged_ltv"] == pytest.approx(0.615385, rel=1e-6)
assert first_ladder["option_payoff"] == pytest.approx(576480.63, abs=1e-2)
assert first_ladder["hedge_cost"] == pytest.approx(34288.79, abs=1e-2)
assert first_ladder["hedged_ltv"] == pytest.approx(0.614452, rel=1e-6)
worst_ladder = ladder_scenarios[-1]
assert worst_ladder["gld_price"] == 690.0