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.
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.
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.
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
) and then use the
Financial Instruments Toolbox™ object-based framework for pricing instruments.
Although toRateSpec supports serial date numbers,
datetime values are recommended instead. The
datetime data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime values, use the datetime function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum");
y = year(t)
y =
2021
There are no plans to remove support for serial date number inputs.