Skip to content

Use the last reset price for the equity swap period in progress - #491

Open
MkGut wants to merge 1 commit into
FinancePy-Org:masterfrom
MkGut:fix/equity-swap-reset-price
Open

MkGut wants to merge 1 commit into
FinancePy-Org:masterfrom
MkGut:fix/equity-swap-reset-price

Conversation

@MkGut

@MkGut MkGut commented Dec 1, 2026

Copy link
Copy Markdown

EquitySwapLeg.value used the spot on the valuation date as the reset price of the period in progress. The return earned since the last reset was therefore dropped, and the leg was valued as if it had just reset.

test_equity_swap_not_in_inception shows it. It builds the stock price at which the equity and float legs balance (Hull, Technical Note 19), so the swap should be worth 0, but the test asserted -25734.69494. It is now 0 to 1e-8.

A second check, a one-year leg on 1,000 shares reset at 100, valued six months in with spot 120 and r = 5%:

value
before 2,986.86
Q * (F - S_reset) * df 22,489.05
Monte Carlo, 2m paths, 95% CI 22,487.02 +/- 23.73
now 22,489.05

Changes:

  • The period in progress pays Q * (F - S_reset), with the forward grown from the current spot.
  • The first period uses the contractual strike as its reset price. On a reset date it is the current spot. For a later period in progress, the observed fixing has to be supplied through a new optional last argument, current_reset_price, on EquitySwapLeg.value and EquitySwap.value. Without it a FinError is raised, since the fixing cannot be inferred.
  • current_price is now required between the effective and maturity dates. Previously the strike was silently used as the spot.
  • test_equity_swap_at_inception passed first_fixing positionally into current_price (a spot of 0.02), which went unnoticed because the reset price moved with it. I removed that argument.

Tests: new unit tests for both cases; tests/unit passes (2,082; 2,080 before). The regression script reports the same existing errors before and after (CDS fixed recovery, FX vanilla option, IBOR swaption). example_equity_swap.py runs.

Not changed here: for periods that have not started, the period-start notional is S * df_idx * df_div rather than the forward S / (df_idx * df_div). For a two-year annual leg (spot 100, 1,000 shares, 5%) that gives 4,624.90 against 4,864.03 from the forwards. I can send that separately if you agree it is wrong.

AI disclosure: found and written by an AI agent (OpenAI gpt-6-luna); reviewed and re-tested by another (Claude Opus 5.5).

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant