# Calculating discountmargin using flat yield

How do you calculate the discount margin of a floating rate bond using flat yield? What is the formula?

I think you mean this:

Another DM variant is this:

Source:

This document has numerical examples.

• Thank you very much! Dec 30, 2020 at 19:08

I am a co-author of that paper. You may want to check out FinancePy which is a beta version of a finance library where I have implemented the code for calculating the discount margin. Here is an example Jupyter notebook that reproduces (almost exactly) a Bloomberg example.

https://github.com/domokane/FinancePy/blob/master/notebooks/products/bonds/FINBONDFRN_CitigroupExample.ipynb

The underlying code is in

https://github.com/domokane/FinancePy/blob/master/financepy/products/bonds/FinBondFRN.py

Contact me at [email protected] if you have any issues or questions regarding FinancePy.

• Can your library also be used for bonds with irregular cashflows? Eg if I have modelled the cashflows from an ABS / RMBS / bespoke investment separately (I don't want your library to do that), can I use your library to calculate the DM of those cashflows? Feb 9, 2021 at 23:09
• It should be possible - you would need to set the internal date and flow schedule (one is a list of dates and the other is a list of floats) - as everything is open in Python this should be possible. Can you add this as a request on github issues github.com/domokane/FinancePy/issues and I can see if I can add a method which makes it easier to do and has some validation checks. Or contact me via [email protected]
– Dom
Feb 10, 2021 at 9:30
• Could you elaborate on what $L_{\text{stub}}$ is or how it is calculated? Apr 30 at 3:29