Get discount factors for input dates for
ratecurve object and
discountfactors were introduced in R2020a as part of a new
object-based framework in the Financial Instruments Toolbox™ which supports end-to-end workflows in instrument modeling and
analysis. For more information, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
Get Discount Factors For Input Dates for an
This example shows how to get discount factors for input dates for an
CurveSettle = datetime(2016,3,2); Data = [2.09 2.47 2.71 3.12 3.43 3.85 4.57 4.58]/100; Dates = datemnth(CurveSettle,12*[1 2 3 5 7 10 20 30]); irdc = IRDataCurve('Zero',CurveSettle,Dates,Data); getDiscountFactors(irdc, CurveSettle+30:30:CurveSettle+720)
ans = 24×1 0.9986 0.9971 0.9956 0.9940 0.9924 0.9907 0.9890 0.9873 0.9855 0.9836 ⋮
CurveObj — Interest-rate curve object
Interest-rate curve object, specified by using
InpDates — Input dates
datetime array | string array | date character vector
Input dates, specified as an
1 vector using a datetime
array, string array, or date character vectors. The input dates must be
Settle date of
To support existing code,
accepts serial date numbers as inputs, but they are not recommended.
F — Discount factors
Discount factors, returned as a vector.
Version HistoryIntroduced in R2008b
R2022b: Serial date numbers not recommended
getDiscountFactors 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.