LUSID can calculate yield to maturity and duration for the following supported instruments:

`Bond`

`ComplexBond`

`InflationLinkedBond`

`InterestRateSwap`

(duration only)

Note: For interest rate swaps, durations are calculated for each leg separately, then aggregated based on the pay/receive direction of each corresponding leg.

To examine the calculations, include the following metrics in a valuation report:

`Analytic/YieldToMaturity`

`Analytic/ModifiedDuration`

`Analytic/MacaulayDuration`

## Yield to maturity

The yield to maturity (YTM) calculation uses the iterative Newton-Raphson method to find a yield where the calculated unit PV matches the unit PV implied by a given bond price by dividing the price by the face value.

Given an effective date, LUSID calculates the total PV of the cashflows that have a payment date after the effective date, discounting these flows using a trial yield value `yt`

. That is:

where:

`i`

is the cashflow index.`CFi`

is the cashflow amount (either fixed or projected).`yt`

is the trial yield value.`h`

is the number of compound periods per year, calculated as 12 divided by the number of months in the payment frequency (for example,`h = 4`

for a bond that pays quarterly).`DCFi`

is the day count fraction until the cashflow is paid. For the first and final cashflows, this is calculated as the year fraction between the start and end dates of the corresponding accrual period, using the day count convention defined on the instrument. For every other cashflow, this is calculated in multiples of`1/h`

(for example, a quarterly bond would have`DCF2 = DCF1 + 0.25`

,`DCF3 = DCF2 + 0.25`

and so on).

This PV is then divided by the principal on the effective date to calculate the unit PV. If the calculated unit PV does not match the target unit PV (from the bond price), then the trial yield value is adjusted as per Newtonâ€™s method and the calculation repeated. If the unit PV matches within a tolerance of 9 decimal places, then the iteration stops and `yt`

is the yield to maturity.

## Duration

Using the PV calculation defined in the previous section, LUSID sets `yt`

to the YTM calculated in that step. The modified duration is:

The Macaulay duration is: