FinancePy
FinancePy copied to clipboard
Bond Key Rate Duration Calculator
Hello @domokane , I would like to work on this issue. Please let me know if it is alright. Thanks you.
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.
Thank you. I am looking at the code base. And once I have a plan, I will discuss with you.
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.
I am attaching the notebook here. Someone else may have an opinion or suggestion.
.ipynb file inside a zipped file.
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.
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.
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 ?