Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EquitySwapLeg.valueused 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_inceptionshows 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%:
Q * (F - S_reset) * dfChanges:
Q * (F - S_reset), with the forward grown from the current spot.strikeas 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, onEquitySwapLeg.valueandEquitySwap.value. Without it aFinErroris raised, since the fixing cannot be inferred.current_priceis now required between the effective and maturity dates. Previously the strike was silently used as the spot.test_equity_swap_at_inceptionpassedfirst_fixingpositionally intocurrent_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/unitpasses (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.pyruns.Not changed here: for periods that have not started, the period-start notional is
S * df_idx * df_divrather than the forwardS / (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