Skip to content

Duration & Metrics for IRS in FinancePy: Validation Against Bond Math by DONALD J. SMITH - #229

Merged
domokane merged 12 commits into
domokane:masterfrom
piper0124:financepy-products-rates-ibor_swap-piper0124
Sep 19, 2026
Merged

domokane merged 12 commits into
domokane:masterfrom
piper0124:financepy-products-rates-ibor_swap-piper0124

Conversation

@piper0124

Copy link
Copy Markdown
Contributor

Wow, Doctor, it's really great to meet you!
Based on Bond Math: The Theory Behind the Formulas, Second Edition, I have implemented duration and other metrics for interest rate swaps in FinancePy(ibor_swap.py) and compared the results with those presented in the Bond Math book(FinancePy>notebooks>products>rates>FINIBORSWAP_ReplicationgBONDMATHDurationExample.ipynb). The results are largely consistent, with small differences likely due to date conventions.
Have a nice day.

@domokane

domokane commented May 23, 2025 •

Copy link
Copy Markdown
Owner

Hi - Can you just have one function. Use the class member fixed_leg_type to determine whether someone is a payer or receiver.

    if fixed_leg_type == SwapTypes.PAY

or

    if fixed_leg_type == SwapTypes.RECEIVE

piper0124 added 3 commits May 26, 2025 09:11
1. Use the class member fixed_leg_type(SwapTypes.PAY or SwapTypes.RECEIVE) to determine whether a counterparty is a buyer or seller, and calculate the Macaulay duration, modified duration, basis point value (BPV), and present value change of the interest rate swap (IRS).
2. Updated the notebook: FINIBORSWAP_ReplicationBONDMATHDurationExample.ipynb.
@piper0124

Copy link
Copy Markdown
Contributor Author
  1. Use the class member fixed_leg_type(SwapTypes.PAY or SwapTypes.RECEIVE) to determine whether a counterparty is a buyer or seller, and calculate the Macaulay duration, modified duration, basis point value (BPV), and present value change of the interest rate swap (IRS).
  2. Updated the notebook: FINIBORSWAP_ReplicationBONDMATHDurationExample.ipynb.
    Thanks.

@domokane
domokane merged commit 2a3e01b into domokane:master Sep 19, 2026
@piper0124

piper0124 commented Sep 21, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

2 participants