Main Content

toRateSpec

Convert IRFunctionCurve object to RateSpec

Description

example

F = toRateSpec(CurveObj,InpDates) computes RateSpec object for input dates for an IRFunctionCurve object. The RateSpec object that is identical to the RateSpec structure created by the function intenvset.

Examples

collapse all

This example shows how to convert an IRFunctionCurve object to a RateSpec. First, an IRFunctionCurve object is created using the function IRFunctionCurve constructor, then a RateSpec structure is created using the toRateSpec method.

irfc = IRFunctionCurve('Forward',today,@(t) polyval([-0.0001 0.003 0.02],t));
toRateSpec(irfc, today+30:30:today+365)
ans = struct with fields:
           FinObj: 'RateSpec'
      Compounding: 2
             Disc: [12x1 double]
            Rates: [12x1 double]
         EndTimes: [12x1 double]
       StartTimes: [12x1 double]
         EndDates: [12x1 double]
       StartDates: 739295
    ValuationDate: 739295
            Basis: 0
     EndMonthRule: 1

Input Arguments

collapse all

Interest-rate curve object, specified by using IRFunctionCurve.

Data Types: object

Input dates, specified as an NINST-by-1 vector using a datetime array, string array, or date character vectors. The input dates must be after the Settle date of IRFunctionCurve.

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

Output Arguments

collapse all

Rate spec, returned as an object. The RateSpec object that is identical to the RateSpec structure created by the function intenvset.

Alternatively, you can convert the RateSpec object to a ratecurve object (see Convert RateSpec to a ratecurve Object) and then use the Financial Instruments Toolbox™ object-based framework for pricing instruments.

Version History

Introduced in R2008b

expand all