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 `y`

. That is:_{t}

where:

`i`

is the cashflow index.`CF`

is the cashflow amount (either fixed or projected)._{i}`y`

is the trial yield value._{t}`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).`DCF`

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_{i}`1/h`

(for example, a quarterly bond would have`DCF`

,_{2}= DCF_{1}+ 0.25`DCF`

and so on)._{3}= DCF_{2}+ 0.25

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 `y`

is the yield to maturity._{t}

## Duration

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

to the YTM calculated in that step. The modified duration is:_{t}

The Macaulay duration is: