FinancePy icon indicating copy to clipboard operation
FinancePy copied to clipboard

Bond Key Rate Duration Calculator

Open domokane opened this issue 5 years ago • 3 comments

domokane avatar Oct 01 '20 19:10 domokane

Hello @domokane , I would like to work on this issue. Please let me know if it is alright. Thanks you.

badalsarkar avatar Mar 09 '21 14:03 badalsarkar

Sure. Take a look at the code. We can discuss how to do it. If possible, I suggest putting as much of the code logic under models rather than putting it under FinBond.

It can then be called from the FinBond class.

I have not checked this but you may want to use this as a test case.

https://blog.deriscope.com/index.php/en/excel-quantlib-key-rate-duration

If you stop or change your mind, let me know.

Regards D

From: BADAL SARKARmailto:[email protected] Sent: 09 March 2021 15:59 To: domokane/FinancePymailto:[email protected] Cc: Dominic O'Kanemailto:[email protected]; Mentionmailto:[email protected] Subject: Re: [domokane/FinancePy] Bond Key Rate Duration Calculator (#33)

Hello @domokanehttps://github.com/domokane , I would like to work on this issue. Please let me know if it is alright. Thanks you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/domokane/FinancePy/issues/33#issuecomment-794009126, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABJ73PLC3OHVT2TBZEIOA7LTCYSSDANCNFSM4SA2V3LQ.

domokane avatar Mar 09 '21 15:03 domokane

Thank you. I am looking at the code base. And once I have a plan, I will discuss with you.

badalsarkar avatar Mar 09 '21 20:03 badalsarkar

Dear @domokane I have done some calculations. I will send you a notebook for your review. If I am on the right track I can incorporate into code together with the test cases.

sagayev avatar Feb 22 '23 10:02 sagayev

I am attaching the notebook here. Someone else may have an opinion or suggestion.

KRD_draft_by_sagayev.zip

.ipynb file inside a zipped file.

sagayev avatar Feb 22 '23 10:02 sagayev

Hello @domokane ,

The Periscope example in the above link does not seem to calculate the modified duration correctly. Their modified duration and the sum of key rate durations are consistent with each other. However, the modified duration is not in line with FinancePy and MS Excel.

sagayev avatar Mar 16 '23 14:03 sagayev

KRD_draft_by_sagayev_Bloomberg.pdf

Dear @domokane,

I have compared my numbers with Bloomberg. They are very close. I also added more comments to explain the code. Please let me know if it seems OK. Also if there is a better approach let me know. I have not used function here. If we can agree on the path I will add it to Bond class as a method.

sagayev avatar Mar 17 '23 08:03 sagayev

Hi - this looks pretty good. The differences are probably due to small details in the price-yield formula. Maybe try implementing it as a function. Please think about where it should go - should it be part of a separate key rate class ?

domokane avatar Apr 09 '23 15:04 domokane