Main Content

ratecurve

Create ratecurve object for interest-rate curve from dates and data

Since R2020a

Description

Build a ratecurve object using ratecurve.

After creating a ratecurve object, you can use the associated object functions forwardrates, discountfactors, and zerorates.

Note

If you have the RateSpec obtained previously from intenvset or toRateSpec for an IRDataCurve or toRateSpec for an IRFunctionCurve, refer to Convert RateSpec to a ratecurve Object.

To price a Swap, FixedBond, FloatBond, FRA, or Deposit instrument, you must create a ratecurve object and then create Discount pricer object.

For more detailed information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

For more information on the available instruments, models, and pricing methods, see Choose Instruments, Models, and Pricers.

Creation

Description

example

ratecurve_obj = ratecurve(Type,Settle,Dates,Rates) creates a ratecurve object.

example

ratecurve_obj = ratecurve(___,Name,Value) creates a ratecurve object using name-value pairs and any of the arguments in the previous syntax. For example, myRC = ratecurve("zero",Settle,ZeroDates,ZeroRates,'Compounding',2,'Basis',5,'InterpMethod',"pchip",'ShortExtrapMethod',"linear",'LongExtrapMethod',"cubic") creates a ratecurve object for a zero curve. You can specify multiple name-value pair arguments.

Input Arguments

expand all

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

Data Types: char | string

Settlement date, specified as a scalar datetime, string, or date character vector.

To support existing code, ratecurve also accepts serial date numbers as inputs, but they are not recommended.

If you use a date character vector or string, the format must be recognizable by datetime because the Settle property is stored as a datetime.

Dates corresponding to the rate data, specified as vector using a datetime array, string array, or date character vectors.

To support existing code, ratecurve also accepts serial date numbers as inputs, but they are not recommended.

If you use a date character vectors or strings, the format must be recognizable by datetime because the Dates property is stored as a datetime.

Interest-rate data for the curve, specified as a scalar numeric.

Data Types: double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: myRC = ratecurve("zero",Settle,ZeroDates,ZeroRates,'Compounding',2,'Basis',5,'InterpMethod',"pchip",'ShortExtrapMethod',"linear",'LongExtrapMethod',"cubic")

Compounding frequency, 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, 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

Interpolation method, specified as the comma-separated pair consisting of 'InterpMethod' and a scalar string or character vector using a supported value. For more information on interpolation methods, see interp1.

Data Types: char | string

Extrapolation method for data before first data, specified as the comma-separated pair consisting of 'ShortExtrapMethod' and a scalar string or character vector using a supported value. For more information on interpolation methods, see interp1.

Data Types: char | string

Extrapolation method for data after last data, specified as the comma-separated pair consisting of 'LongExtrapMethod' and a scalar string or character vector using a supported value. For more information on interpolation methods, see interp1.

Data Types: char | string

Properties

expand all

Type of interest-rate curve, returned as a string.

Data Types: string

Compounding frequency, returned as a scalar numeric.

Data Types: double

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

Data Types: double

Dates corresponding to the rate data, returned as a datetime.

Data Types: datetime

Rates corresponding to dates data, returned as vector.

Data Types: datetime

Settlement date, returned as a datetime.

Data Types: datetime

Interpolation method, returned as a scalar string.

Data Types: string

Short extrapolation method, returned as a scalar string.

Data Types: string

Log extrapolation method, returned as a scalar string.

Data Types: string

Object Functions

forwardratesCalculate forward rates for ratecurve object
discountfactorsCalculate discount factors for a ratecurve object
zeroratesCalculate zero rates for ratecurve object
irbootstrapBootstrap interest-rate curve from market data

Examples

collapse all

Create a ratecurve object using ratecurve.

Settle = datetime(2018,9,15);
Type = "zero";
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
 
myRC = ratecurve("zero",Settle,ZeroDates,ZeroRates,'Compounding',2,'Basis',5,'InterpMethod',"pchip",'ShortExtrapMethod',"linear",'LongExtrapMethod',"cubic")
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: 2
                Basis: 5
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2018
         InterpMethod: "pchip"
    ShortExtrapMethod: "linear"
     LongExtrapMethod: "cubic"

Version History

Introduced in R2020a

expand all