| Fixed-Income Toolbox™ | ![]() |
CurveObj = IRFunctionCurve.fitFunction(Type, Settle, FunctionHandle, Instruments, IRFitOptionsObj) CurveObj = IRFunctionCurve.fitFunction(Type, Settle, FunctionHandle, Instruments, IRFitOptionsObj, Parameter1', Value1, 'Parameter2', Value2, ...)
| Type | Type of interest-rate curve for a bond: zero, forward, or discount. |
| Settle | Scalar or column vector of settlement dates. |
| FunctionHandle | Function handle that defines the interest-rate curve. The function handle takes two numeric vectors (time-to-maturity and a vector of function coefficients) and returns one numeric output (interest rate or discount factor). For more information on defining a function handle, see the MATLAB Programming Fundamentals documentation. |
| Instruments | N-by-4 data matrix for Instruments where the first column is Settle date, the second column is Maturity, the third column is dirty price, and the fourth column is a CouponRate for the bond. |
| IRFitOptionsObj | Object constructed from IRFitOptions. |
| Compounding | (Optional) Compounding value for a bond:
|
| Basis | (Optional) Day-count basis of the bond. A vector of integers.
|
For each bond Instrument, you can specify the following additional instrument parameters as parameter/value pairs by prepending the word Instrument to the parameter field. For example, prepending InstrumentBasis distinguishes a bond instrument's Basis value from the curve's Basis value.
CouponRate | (Optional) Decimal number indicating the annual percentage rate used to determine the coupons payable on a bond. |
Period | (Optional) Coupons per year of the bond. A vector of integers. Allowed values are 0, 1, 2 (default), 3, 4, 6, and 12. |
Basis | (Optional) Day-count basis of the bond. A vector of integers.
|
EndMonthRule | (Optional) End-of-month rule. A vector. This rule applies only when Maturity is an end-of-month date for a month having 30 or fewer days. 0 = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. 1 = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month. |
IssueDate | (Optional) Date when an instrument was issued. |
FirstCouponDate | (Optional) Date when a bond makes its first coupon payment. When FirstCouponDate and LastCouponDate are both specified, FirstCouponDate takes precedence in determining the coupon payment structure. |
LastCouponDate | (Optional) Last coupon date of a bond before the maturity date. In the absence of a specified FirstCouponDate, a specified LastCouponDate determines the coupon structure of the bond. The coupon structure of a bond is truncated at the LastCouponDate regardless of where it falls and will be followed only by the bond's maturity cash flow date. |
Face | (Optional) Face or par value. Default = 100. |
Note When using Instrument parameter/value pairs, you can specify simple interest for a bond by specifying the InstrumentPeriod value as 0. If InstrumentBasis and InstrumentPeriod are not specified for a bond, the following default values are used: Basis is 0 (act/act) and Period is 2. |
CurveObj = IRFunctionCurve.fitFunction(Type, Settle, FunctionHandle, Instruments, IRFitOptionsObj, 'Parameter1', Value1, 'Parameter2', Value2, ...) fits a bond to a custom fitting function. interest-rate curve to market data. You must enter the optional arguments for Basis and Compounding as parameter/value pairs.
Settle = repmat(datenum('30-Apr-2008'),[6 1]);
Maturity = [datenum('07-Mar-2009');datenum('07-Mar-2011');...
datenum('07-Mar-2013');datenum('07-Sep-2016');...
datenum('07-Mar-2025');datenum('07-Mar-2036')];
DirtyPrice = [100.1;100.1;100.8;96.6;103.3;96.3];
CouponRate = [0.0400;0.0425;0.0450;0.0400;0.0500;0.0425];
Instruments = [Settle Maturity DirtyPrice CouponRate];
CurveSettle = datenum('30-Apr-2008');
OptOptions = optimset('lsqnonlin');
OptOptions = optimset(OptOptions,'display','iter');
functionHandle = @(t,theta) polyval(theta,t);
CustomModel = IRFunctionCurve.fitFunction('Zero', CurveSettle, ...
functionHandle,Instruments, ...
IRFitOptions([.05 .05 .05],'FitType','price',...
'OptOptions',OptOptions));
Norm of First-order
Iteration Func-count f(x) step optimality CG-iterations
0 4 38036.7 4.92e+004
1 8 38036.7 10 4.92e+004 0
2 12 38036.7 2.5 4.92e+004 0
3 16 38036.7 0.625 4.92e+004 0
4 20 38036.7 0.15625 4.92e+004 0
5 24 30741.5 0.0390625 1.72e+005 0
6 28 30741.5 0.078125 1.72e+005 0
7 32 30741.5 0.0195312 1.72e+005 0
8 36 28713.6 0.00488281 2.33e+005 0
9 40 20323.3 0.00976562 9.47e+005 0
10 44 20323.3 0.0195312 9.47e+005 0
11 48 20323.3 0.00488281 9.47e+005 0
12 52 20323.3 0.0012207 9.47e+005 0
13 56 19698.8 0.000305176 1.08e+006 0
14 60 17493 0.000610352 7e+006 0
15 64 17493 0.0012207 7e+006 0
16 68 17493 0.000305176 7e+006 0
17 72 15455.1 7.62939e-005 2.25e+007 0
18 76 15455.1 0.000177558 2.25e+007 0
19 80 13317.1 3.8147e-005 3.18e+007 0
20 84 12867.9 7.62939e-005 7.84e+007 0
21 88 11779.8 7.62939e-005 7.58e+006 0
22 92 11747.6 0.000152588 1.46e+005 0
23 96 11720.9 0.000305176 2.48e+005 0
24 100 11667.2 0.000610352 1.48e+005 0
25 104 11558.5 0.0012207 4.47e+005 0
26 108 11335.4 0.00244141 1.58e+005 0
27 112 10864 0.00488281 1.61e+005 0
28 116 9797.68 0.00976562 6.85e+005 0
29 120 6884.03 0.0195312 5.79e+005 0
30 124 6884.03 0.037498 5.79e+005 0
31 128 3216.51 0.00937449 1.75e+006 0
32 132 607.317 0.018749 2.94e+006 0
33 136 12.7284 0.0253662 3e+006 0
34 140 0.0760939 0.00153457 4.88e+004 0
35 144 0.0731652 3.58678e-006 24.6 0
36 148 0.0731652 6.04329e-008 0.0213 0
Optimization terminated: relative function value
changing by less than OPTIONS.TolFun.@IRFitOptions, @IRFunctionCurve
![]() | convfactor | fitNelsonSiegel | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |