Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

piper0124
Copy link

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
Copy link
Owner

domokane commented May 23, 2025

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
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.

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