Examples#

This gallery walks through every public feature of financialkit.fixed_income: bond prices and yields, duration and convexity, yield-curve construction, immunization and swaps. Each script illustrates one dated breakthrough from the history page.

See also the narrative tutorial:

Each script in this gallery is self-contained and can be run directly with python examples/fixed_income/<section>/<script>.py.

Sections#

  • bonds – yield to maturity, accrued interest, and a coupon bond as a portfolio of STRIPS.

  • duration – Macaulay, modified and Fisher-Weil duration, convexity, and key rate durations.

  • curves – forward rates, McCulloch splines, bootstrapping, Nelson-Siegel and Svensson fits, and the principal components of curve moves.

  • immunization – Redington’s conditions and the Fong-Vasicek \(M^2\) bound.

  • swaps – the IBM-World Bank currency swap and the plain-vanilla interest-rate swap.

Bonds#

Pricing a bond off a single yield and off a curve of zero-coupon prices.

Inside the Yield Book: yield to maturity

Inside the Yield Book: yield to maturity

STRIPS: a bond as a portfolio of zeros

STRIPS: a bond as a portfolio of zeros

Yield curves#

Forward rates, bootstrapped, spline and parametric curves, and the factors that move them.

Lutz: forward rates

Lutz: forward rates

McCulloch’s spline discount function

McCulloch's spline discount function

Carleton-Cooper bootstrapping

Carleton-Cooper bootstrapping

Nelson-Siegel

Nelson-Siegel

Litterman-Scheinkman: level, slope, curvature

Litterman-Scheinkman: level, slope, curvature

Svensson

Svensson

Duration and convexity#

From Macaulay’s average time to payment to Ho’s key rate durations.

Macaulay duration

Macaulay duration

Hicks: duration as an elasticity (modified duration)

Hicks: duration as an elasticity (modified duration)

Fisher-Weil duration

Fisher-Weil duration

Bierwag-Kaufman-Toevs: convexity

Bierwag-Kaufman-Toevs: convexity

Ho’s key rate durations

Ho's key rate durations

Immunization#

Protecting a surplus against parallel and non-parallel rate moves.

Redington immunization

Redington immunization

Fong-Vasicek M-squared

Fong-Vasicek M-squared

Swaps#

Swaps valued as the difference between two bonds.

The IBM-World Bank currency swap

The IBM-World Bank currency swap

The plain-vanilla interest-rate swap

The plain-vanilla interest-rate swap

Gallery generated by Sphinx-Gallery