In R2017b, the specification of optional input arguments has changed. While the previous ordered inputs syntax is still supported, it may no longer be supported in a future release. Use the optional name-value pair inputs: Period, Basis, EndMonthRule, IssueDate,FirstCouponDate, LastCouponDate, StartDate,Face, CompoundingFrequency, DiscountBasis, and LastCouponInterest.

example

example

Examples

collapse all

This example shows how to compute a Federal National Mortgage Association (FNMA) 4 3/8 spread over a Treasury spot curve and plot the results.

RefMaturity = [datenum('02/27/2003');
datenum('05/29/2003');
datenum('10/31/2004');
datenum('11/15/2007');
datenum('11/15/2012');
datenum('02/15/2031')];

RefCpn = [0;
0;
2.125;
3;
4;
5.375] / 100;

RefPrices =  [99.6964;
99.3572;
100.3662;
99.4511;
99.4299;
106.5756];

RefBonds = [RefPrices, RefMaturity, RefCpn];
Settle   = datenum('26-Nov-2002');
[ZeroRates, CurveDates] = zbtprice(RefBonds(:, 2:end), ...
RefPrices, Settle)
ZeroRates = 6×1

0.0121
0.0127
0.0194
0.0317
0.0423
0.0550

CurveDates = 6×1

731639
731730
732251
733361
735188
741854

% FNMA 4 3/8 maturing 10/06 at 4.30 pm Tuesday
Price    = 105.484;
Coupon   = 0.04375;
Maturity = datenum('15-Oct-2006');

% All optional inputs are supposed to be accounted by default,
% except the accrued interest under 30/360 (SIA), so:
Period = 2;
Basis  = 1;
SpotInfo = [CurveDates, ZeroRates];

% Compute static spread over treasury curve, taking into account
% the shape of curve as derived by bootstrapping method embedded

Maturity, Period, Basis)
plot(CurveDates, ZeroRates*100, 'b', CurveDates, ...
legend({'Treasury'; 'FNMA 4 3/8'})
xlabel('Curve Dates')
ylabel('Spot Rate [%]')
grid; This example shows how to compute a Federal National Mortgage Association (FNMA) 4 3/8 spread over a Treasury spot curve using datetime inputs for Settle and Maturity and a table for SpotInfo and plot the results.

RefMaturity = [datenum('02/27/2003');
datenum('05/29/2003');
datenum('10/31/2004');
datenum('11/15/2007');
datenum('11/15/2012');
datenum('02/15/2031')];

RefCpn = [0;
0;
2.125;
3;
4;
5.375] / 100;

RefPrices =  [99.6964;
99.3572;
100.3662;
99.4511;
99.4299;
106.5756];

RefBonds = [RefPrices, RefMaturity, RefCpn];
Settle   = datetime('26-Nov-2002','Locale','en_US');
[ZeroRates, CurveDates] = zbtprice(RefBonds(:, 2:end), ...
RefPrices, Settle)
ZeroRates = 6×1

0.0121
0.0127
0.0194
0.0317
0.0423
0.0550

CurveDates = 6x1 datetime
27-Feb-2003
29-May-2003
31-Oct-2004
15-Nov-2007
15-Nov-2012
15-Feb-2031

% FNMA 4 3/8 maturing 10/06 at 4.30 pm Tuesday
Price    = 105.484;
Coupon   = 0.04375;
Maturity = datetime('15-Oct-2006','Locale','en_US');

% All optional inputs are accounted by default,
% except the accrued interest under 30/360 (SIA), so:
Period = 2;
Basis  = 1;

SpotInfo = table(CurveDates, ZeroRates);

% Compute static spread over treasury curve, taking into account
% the shape of curve as derived by bootstrapping method embedded

Maturity, Period, Basis)
plot(CurveDates, ZeroRates*100, 'b', CurveDates, ...
legend({'Treasury'; 'FNMA 4 3/8'})
xlabel('Curve Dates')
ylabel('Spot Rate [%]')
grid; Input Arguments

collapse all

Spot-rates information, specified as matrix of two columns, an annualized term structure created by intenvset (Financial Instruments Toolbox), or a table.

• Matrix of two columns— The first column is the SpotDate, and the second column, ZeroRates, is the zero-rate corresponding to maturities on the SpotDate. It is recommended that the spot-rates are spaced as evenly apart as possible, perhaps one that is built from 3-months deposit rates. For example, using the 3-month deposit rates:

SpotInfo = ...
[datenum('2-Jan-2004') ,  0.03840;
datenum('2-Jan-2005') ,  0.04512;
datenum('2-Jan-2006') ,  0.05086];

• Annualized term structure — Refer to intenvset (Financial Instruments Toolbox) to create an annualized term structure. For example:

Settle = datenum('1-Jan-2004');
Rates = [0.03840; 0.04512; 0.05086];
EndDates = [datenum('2-Jan-2004'); datenum('2-Jan-2005');...
datenum('2-Jan-2006')];
SpotInfo = intenvset('StartDates' , Settle  ,...
'Rates'      , Rates   ,...
'EndDates'   , EndDates,...
'Compounding', 2       ,...
'Basis'      , 0);

• Table — If SpotInfo is a table, the first column can be either a serial date number, date character vector, or datetime array. The second column is numerical data representing zero rates. For example:

ZeroRates = … [0.012067955808764;0.012730933424479;0.019360902068703;0.031704525214251;0.042306085224510;0.054987415342936];
CurveDates = [731639;731730;732251;733361;735188;741854];
Settle   = datenum('26-Nov-2002');
Price    = 105.484;
Coupon   = 0.04375;
Maturity = datenum('15-Oct-2006');
Period = 2;
Basis  = 1;
SpotInfo = table(datestr(CurveDates), ZeroRates);

Data Types: double | table | struct

Price for every \$100 notional amount of bonds whose spreads are computed, specified as numeric value using a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector.

Data Types: double

Annual coupon rate of bonds whose spreads are computed, specified as decimal value using a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector.

Data Types: double

Settlement date of the bond, specified as a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays. The Settle date must be before the Maturity date.

Data Types: double | char | datetime

Maturity date of the bond, specified as a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays.

Data Types: double | char | datetime

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Number of coupon payments per year, specified as the comma-separated pair consisting of 'Period' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using the values: 0, 1, 2, 3, 4, 6, or 12.

Data Types: double

Day-count of the instrument, specified as the comma-separated pair consisting of 'Basis' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using a supported value:

• 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

Data Types: double

End-of-month rule flag, specified as the comma-separated pair consisting of 'EndMonthRule' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS 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 coupon payment date is always the same numerical day of the month.

• 1 = Set rule on, meaning that a bond coupon payment date is always the last actual day of the month.

Data Types: logical

Bond Issue date, specified as the comma-separated pair consisting of 'IssueDate' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays.

If you do not specify an IssueDate, the cash flow payment dates are determined from other inputs.

Data Types: double | char | datetime

Irregular or normal first coupon date, specified as the comma-separated pair consisting of 'FirstCouponDate' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays.

If you do not specify a FirstCouponDate, the cash flow payment dates are determined from other inputs.

Data Types: double | char | datetime

Irregular or normal last coupon date, specified as the comma-separated pair consisting of 'LastCouponDate' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays.

If you do not specify a LastCouponDate, the cash flow payment dates are determined from other inputs.

Data Types: double | char | datetime

Forward starting date of payments, specified as the comma-separated pair consisting of 'StartDate' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector using serial date numbers, date character vectors, or datetime arrays. The StartDate is when a bond actually starts (the date from which a bond cash flow is considered). To make an instrument forward-starting, specify this date as a future date.

If you do not specify a StartDate, the effective start date is the Settle date.

Data Types: double | char | datetime

Face value of the bond, specified as the comma-separated pair consisting of 'Face' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector.

Data Types: double

Compounding frequency for yield calculation, specified as the comma-separated pair consisting of 'CompoundingFrequency' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector.

• 1 — Annual compounding

• 2 — Semiannual compounding

• 3 — Compounding three times per year

• 4 — Quarterly compounding

• 6 — Bimonthly compounding

• 12 — Monthly compounding

Note

By default, SIA bases (0-7) and BUS/252 use a semiannual compounding convention and ICMA bases (8-12) use an annual compounding convention.

Data Types: double

Basis used to compute the discount factors for computing the yield, specified as the comma-separated pair consisting of 'DiscountBasis' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector. Values are:

• 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

Note

If a SIA day-count basis is defined in the Basis input argument and there is no value assigned for DiscountBasis, the default behavior is for SIA bases to use the actual/actual day count to compute discount factors.

If an ICMA day-count basis or BUS/252 is defined in the Basis input argument and there is no value assigned for DiscountBasis, the specified bases from the Basis input argument are used.

Data Types: double

Compounding convention for computing the yield of a bond in the last coupon period, specified as the comma-separated pair consisting of 'LastCouponInterest' and a scalar or a NUMBONDS-by-1 or 1-by-NUMBONDS vector. LastCouponInterest is based on only the last coupon and the face value to be repaid. Acceptable values are:

• simple

• compound

Data Types: char | cell

Output Arguments

collapse all

Static spread to benchmark, returned in basis points as a scalar or a NUMBONDS-by-1 vector.

 Krgin, D. Handbook of Global Fixed Income Calculations. Wiley, 2002.

 Mayle, J. "Standard Securities Calculations Methods: Fixed Income Securities Formulas for Analytic Measures." SIA, Vol 2, Jan 1994.

 Stigum, M., Robinson, F. Money Market and Bond Calculation. McGraw-Hill, 1996.