FinancePy icon indicating copy to clipboard operation
FinancePy copied to clipboard

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

Open piper0124 opened this issue 7 months ago • 2 comments

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.

piper0124 avatar May 23 '25 07:05 piper0124

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

domokane avatar May 23 '25 11:05 domokane

  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.

piper0124 avatar May 26 '25 05:05 piper0124