JuliaActuary

Practical, extensible, and open-source actuarial modeling and analysis.

Given rates and maturities, we can fit the yield curves with different techniques in Yields.jl.

Below, we specify that the rates should be interpreted as `Continuous`

ly compounded zero rates:

```
using Yields
rates = Continuous.([0.01, 0.01, 0.03, 0.05, 0.07, 0.16, 0.35, 0.92, 1.40, 1.74, 2.31, 2.41] ./ 100)
mats = [1/12, 2/12, 3/12, 6/12, 1, 2, 3, 5, 7, 10, 20, 30]
```

Then fit the rates under four methods:

Nelson-Siegel

Nelson-Siegel-Svensson

Bootstrapping with splines (the default

`Bootstrap`

option)Bootstrapping with linear splines

```
ns = Yields.Zero(NelsonSiegel(), rates,mats)
nss = Yields.Zero(NelsonSiegelSvensson(), rates,mats)
b = Yields.Zero(Bootstrap(), rates,mats)
bl = Yields.Zero(Bootstrap(Yields.LinearSpline()), rates,mats)
```

That's it! We've fit the rates using four different techniques. These can now be used in a variety of ways, such as calculating the `present_value`

, `duration`

, or `convexity`

of different cashflows if you imported ActuaryUtilities.jl

A visualization of the different curves:

This example, complete with the code to plot/animate the curves is in the notebook below. To use Pluto to run the notebook:

Open a Julia REPL and copy and paste the following:

```
# install these dependencies
import Pkg; Pkg.add("Pluto")
# use and start Pluto
using Pluto; Pluto.run()
```

In the Pluto window that opens, enter this URL into the

`Open from file:`

box:

`https://raw.githubusercontent.com/JuliaActuary/Learn/master/Yield_Curve_fitting.jl`

The packages in JuliaActuary are open-source and liberally licensed (MIT License) to allow wide private and commercial
usage of the packages, like the base Julia language and many other packages in the ecosystem. See terms of this site.

© JuliaActuary Contributors. Last modified: January 14, 2023. Website built with Franklin.jl and Julia.