# numberOfBonds (3) - Linux Man Pages

## numberOfBonds: Discount curve fitted to a set of fixed-coupon bonds.

## NAME

QuantLib::FittedBondDiscountCurve - **Discount** curve fitted to a set of fixed-coupon bonds.

## SYNOPSIS

#include <ql/termstructures/yield/fittedbonddiscountcurve.hpp>

Inherits **QuantLib::YieldTermStructure**, and **QuantLib::LazyObject**.

### Classes

class **FittingMethod**

*Base fitting method used to construct a fitted bond discount curve. *

### Public Member Functions

**Constructors**

**FittedBondDiscountCurve** (**Natural** settlementDays, const **Calendar** &calendar, const std::vector< boost::shared_ptr< **FixedRateBondHelper** > > &instruments, const **DayCounter** &dayCounter, const **FittingMethod** &fittingMethod, **Real** accuracy=1.0e-10, Size maxEvaluations=10000, const Array &guess=Array(), Real simplexLambda=1.0)

*reference date based on current evaluation date *

**FittedBondDiscountCurve** (const **Date** &referenceDate, const std::vector< boost::shared_ptr< **FixedRateBondHelper** > > &instruments, const **DayCounter** &dayCounter, const **FittingMethod** &fittingMethod, **Real** accuracy=1.0e-10, Size maxEvaluations=10000, const Array &guess=Array(), Real simplexLambda=1.0)

*curve reference date fixed for life of curve *

**Inspectors**

Size **numberOfBonds** () const

*total number of bonds used to fit the yield curve *

**Date** **maxDate** () const

*the latest date for which the curve can return values *

const **FittingMethod** & **fitResults** () const

*class holding the results of the fit *

**Observer interface**

### Friends

## Detailed Description

**Discount** curve fitted to a set of fixed-coupon bonds.

This class fits a discount function $ d(t) $ over a set of bonds, using a user defined fitting method. The discount function is fit in such a way so that all cashflows of all input bonds, when discounted using $ d(t) $, will reproduce the set of input bond prices in an optimized sense. Minimized price errors are weighted by the inverse of their respective bond duration.

The **FittedBondDiscountCurve** class acts as a generic wrapper, while its inner class **FittingMethod** provides the implementation details. Developers thus need only derive new fitting methods from the latter.

** Example: ** **compares various bond discount curve fitting methodologies **

**Warning**

- The method can be slow if there are many bonds to fit. Speed also depends on the particular choice of fitting method chosen and its convergence properties under optimization. See also todo list for BondDiscountCurveFittingMethod.

**Possible enhancements**

- refactor the bond helper class so that it is pure virtual and returns a generic bond or its cash flows. Derived classes would include helpers for fixed-rate and zero-coupon bonds. In this way, both bonds and bills can be used to fit a discount curve using the exact same machinery. At present, only fixed-coupon bonds are supported. An even better way to move forward might be to get rate helpers to return cashflows, in which case this class could be used to fit any set of cash flows, not just bonds.

**Possible enhancements**

- add more fitting diagnostics: smoothness, standard deviation, student-t test, etc. Generic smoothness method may be useful for smoothing splines fitting. See Fisher, M., D. Nychka and D. Zervos: 'Fitting the term structure of interest rates with smoothing splines.' Board of Governors of the Federal Reserve System, Federal Resere Board Working Paper, 95-1.

**Possible enhancements**

- add extrapolation routines

**Examples: **

## Member Function Documentation

### void update () [virtual]

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Reimplemented from **LazyObject**.

## Author

Generated automatically by Doxygen for QuantLib from the source code.