Main Content

IRFunctionCurve

Construct interest-rate curve object from function handle or function and fit to market data

Description

Build a IRFunctionCurve object using IRFunctionCurve.

After you create an IRFunctionCurve object, you can fit the bond using the following functions.

Object FunctionDescription
getForwardRates

Returns forward rates for input dates.

getZeroRates

Returns zero rates for input dates.

getDiscountFactors

Returns discount factors for input dates.

getParYields

Returns par yields for input dates.

toRateSpec

Converts to be a RateSpec object.

This RateSpec structure is identical to the RateSpec produced by the function intenvset.

Alternatively, you can create an IRFunctionCurve object using the following methods.

MethodDescription
fitNelsonSiegel

Fits a Nelson-Siegel function to market data.

fitSvensson

Fits a Svensson function to market data.

fitSmoothingSpline

Fits a smoothing spline function to market data.

fitFunction

Fits a custom function to market data.

For more detailed information on this workflow, see Interest-Rate Curve Objects and Workflow.

Creation

Description

example

IRFunctionCurve_obj = IRFunctionCurve(Type,Settle,FunctionHandle) creates an interest-rate curve object directly by specifying a function handle and sets properties and creates an IRFunctionCurve object. .

example

IRFunctionCurve_obj = IRFunctionCurve(___,Name,Value) sets properties using optional name-value pairs and any of the arguments in the previous syntax. For example, IRFunctionCurve_obj = IRFunctionCurve('Forward',today,@(t) polyval([-0.0001 0.003 0.02],t)) creates an IRFunctionCurve object for a forward curve. You can specify multiple name-value pair arguments.

Input Arguments

expand all

Type of interest-rate curve, specified as a scalar string or character vector for one of the supported types.

Data Types: char | string

Settlement date for the curve, specified as a scalar datetime, serial date number, date character vector, or date string.

Data Types: double | char | string | datetime

Dates corresponding to the rate data, specified as a function handle. The function handle requires one numeric input (time-to-maturity) and returns one numeric output (interest rate or discount factor). For more information on creating a function handle, see Create Function Handle.

Data Types: function_handle

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: IRFunctionCurve_obj = IRFunctionCurve('Forward',today,@(t) polyval([-0.0001 0.003 0.02],t))

Compounding frequency per-year for the curve, specified as the comma-separated pair consisting of 'Compounding' and a scalar numeric using the supported values: –1, 0, 1, 2, 3, 4, 6, or 12.

Data Types: double

Day count basis of the bond, specified as the comma-separated pair consisting of 'Basis' and a scalar integer.

  • 0 — actual/actual

  • 1 — 30/360 (SIA)

  • 2 — actual/360

  • 3 — actual/365

  • 4 — 30/360 (PSA)

  • 5 — 30/360 (ISDA)

  • 6 — 30/360 (European)

  • 7 — actual/365 (Japanese)

  • 8 — actual/actual (ICMA)

  • 9 — actual/360 (ICMA)

  • 10 — actual/365 (ICMA)

  • 11 — 30/360E (ICMA)

  • 12 — actual/365 (ISDA)

  • 13 — BUS/252

For more information, see Basis.

Data Types: double

Curve parameters, specified as the comma-separated pair consisting of 'Parameters' and a numeric value.

Data Types: double

Properties

expand all

This property is read-only.

Instrument type, returned as a string.

Data Types: string

This property is read-only.

Settlement date for the curve, returned as a datetime.

Data Types: datetime

This property is read-only.

Function handle that defines the interest-rate curve, returned as a scalar function handle.

Data Types: function_handle

This property is read-only.

Compounding frequency per-year for curve, returned as a scalar numeric.

Data Types: double

This property is read-only.

Day count basis of the bond, returned as a scalar integer.

Data Types: double

This property is read-only.

Curve parameters, returned as a numeric value.

Data Types: double

Object Functions

getForwardRatesGet forward rates for input dates for IRFunctionCurve
getZeroRatesGet zero rates for input dates for IRFunctionCurve
getDiscountFactorsGet discount factors for input dates for IRFunctionCurve
getParYieldsGet par yields for input dates for IRFunctionCurve
toRateSpecConvert IRFunctionCurve object to RateSpec

Examples

collapse all

This example shows how to create an IRFunctionCurve object for a forward interest-rate curve.

irfc = IRFunctionCurve('Forward',today,@(t) polyval([-0.0001 0.003 0.02],t))
irfc = 
			 Type: Forward
		   Settle: 738400 (01-Sep-2021)
	  Compounding: 2
			Basis: 0 (actual/actual)

Introduced in R2008b