Documentation

pyld2zero

Zero curve given par yield curve

Syntax

[ZeroRates, CurveDates] = pyld2zero(ParRates, CurveDates, Settle)
[ZeroRates, CurveDates] = pyld2zero(ParRates, CurveDates, Settle,
Name, Value)

In R2015b, 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 new optional name-value pair inputs: InputCompounding, InputBasis, OutputCompounding, and OutputBasis.

Input Arguments

ParRates

Column vector of annualized implied par yield rates, as decimal fractions. (Par yields = coupon rates.) In aggregate, the yield rates in ParRates constitute an implied par yield curve for the investment horizon represented by CurveDates.

CurveDates

Column vector of maturity dates that correspond to the par rates, specified as serial date numbers, date character vectors, or datetime arrays.

Settle

Serial date number, date character vector, or datetime array that is the common settlement date for the par rates.

Name-Value Pair 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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: [ZeroRates,CurveDates] = pyld2zero(ParRates, CurveDates, Settle,'OutputCompounding',3,'OutputBasis',5,'InputCompounding',4,'InputBasis',5)

'OutputCompounding' — Compounding frequency of output zero ratesif OutputCompounding is 0 (simple), -1 (continuous), or 365 (daily), the par rate InputCompounding must also be specified a valid value. If OutputCompounding is not specified, it is assigned the value specified for InputCompounding. If neither InputCompounding nor OutputCompounding are specified, the default is 2 (semiannual) for both. (default) | scalar

Compounding frequency of the output zero rates, specified as a scalar with allowed values:

  • 0 — Simple interest (no compounding, zero rates only)

  • 1 — Annual compounding

  • 2 — Semiannual compounding (default)

  • 3 — Compounding three times per year

  • 4 — Quarterly compounding

  • 6 — Bimonthly compounding

  • 12 — Monthly compounding

  • 365 — Daily compounding (zero rates only)

  • -1 — Continuous compounding (zero rates only)

Data Types: single | double

'OutputBasis' — Day count basis of output zero ratesif OutputBasis is not specified, it is assigned the value specified for InputBasis. If neither InputBasis nor OutputBasis are specified, the default is 0 (actual/actual) for both. (default) | scalar

Day count basis of output zero rates, specified as a scalar with possible values:

  • 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: single | double

'InputCompounding' — Compounding frequency of input par ratesif OutputCompounding is 1, 2, 3, 4, 6, or 12, and InputCompounding is not specified, it is assigned the value of OutputCompounding. If OutputCompounding is 0 (simple), -1 (continuous), or 365 (daily), a valid InputCompounding value must also be specified. If neither InputCompounding nor OutputCompounding are specified, the default is 2 (semiannual) for both. (default) | scalar

Compounding frequency of the input par rates, specified as a scalar with allowed values:

  • 1 — Annual compounding

  • 2 — Semiannual compounding (default)

  • 3 — Compounding three times per year

  • 4 — Quarterly compounding

  • 6 — Bimonthly compounding

  • 12 — Monthly compounding

Data Types: single | double

'InputBasis' — Day count basis of input par ratesif InputBasis is not specified, it is assigned the value specified for OutputBasis. If neither InputBasis nor OutputBasis are specified, the default is 0 (actual/actual) for both. (default) | scalar

Day count basis of input par rates, specified as a scalar with possible values:

  • 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: single | double

Description

[ZeroRates, CurveDates] = pyld2zero(ParRates, CurveDates, Settle) returns a zero curve given a par yield curve and its maturity dates.

[ZeroRates, CurveDates] = pyld2zero(ParRates, CurveDates, Settle, Name, Value) returns a zero curve given a par yield curve and its maturity dates using optional name-value pair arguments for InputCompounding, InputBasis, OutputCompounding, and OutputBasis.

ZeroRates

Column vector of decimal fractions. In aggregate, the rates in ZeroRates constitute a zero curve for the investment horizon represented by CurveDates.

CurveDates

Column vector of maturity dates corresponding to the zero rates. This vector is the same as the input vector CurveDates, but is sorted by ascending maturity. If either input for CurveDates or Settle is a datetime array, CurveDates is returned as a datetime array. Otherwise, it will be returned as a serial date number.

Examples

collapse all

Compute Zero Curve Given Par Yield Curve

Define the settlement date, maturity, and zero rates.

Settle = datenum('01-Feb-2013');
CurveDates = datemnth(Settle,12*[1 2 3 5 7 10 20 30]');
ZeroRates = [.11 0.30 0.64 1.44 2.07 2.61 3.29 3.55]'/100;
InputCompounding = 2;
InputBasis = 1;
OutputCompounding = 2;
OutputBasis = 1;

Compute par yield curve from zero rates.

ParRates = zero2pyld(ZeroRates, CurveDates, Settle,'InputCompounding',2,...
'InputBasis',1,'OutputCompounding',2,'OutputBasis',1)
ParRates =

    0.0011
    0.0030
    0.0064
    0.0142
    0.0201
    0.0251
    0.0309
    0.0330

Compute zero curve from the par yield curve.

ZeroRates = pyld2zero(ParRates, CurveDates, Settle,'InputCompounding',2,...
'InputBasis',1,'OutputCompounding',2,'OutputBasis',1)
ZeroRates =

    0.0011
    0.0030
    0.0064
    0.0144
    0.0207
    0.0261
    0.0329
    0.0355

Compute Zero Curve Given Par Yield Curve Using datetime Inputs

Use datetime inputs to compute the zero curve given the par yield curve.

Settle = datenum('01-Feb-2013');

CurveDates = [datenum('01-Feb-2014')
    datenum('01-Feb-2015')
    datenum('01-Feb-2016')
    datenum('01-Feb-2018')
    datenum('01-Feb-2020')
    datenum('01-Feb-2023')
    datenum('01-Feb-2033')
    datenum('01-Feb-2043')];

OriginalParRates = [0.11 0.30 0.64 1.42 2.02 2.51 3.10 3.31]'/100;

InputCompounding = 1;
InputBasis = 0;
OutputCompounding = 1;
OutputBasis = 0;

Settle = datetime(Settle, 'ConvertFrom', 'datenum','Locale','en_US');
CurveDates = datetime(CurveDates, 'ConvertFrom', 'datenum','Locale','en_US');
[ZeroRates Dates] = pyld2zero(OriginalParRates, CurveDates, Settle, ...
'OutputCompounding', OutputCompounding, 'OutputBasis', OutputBasis, ...
'InputCompounding', InputCompounding, 'InputBasis', InputBasis)
ZeroRates =

    0.0011
    0.0030
    0.0064
    0.0144
    0.0207
    0.0261
    0.0329
    0.0356


Dates = 

   01-Feb-2014
   01-Feb-2015
   01-Feb-2016
   01-Feb-2018
   01-Feb-2020
   01-Feb-2023
   01-Feb-2033
   01-Feb-2043

Demonstrate a Roundtrip From pyld2zero to zero2pyld

Given the following a par yield curve and its maturity dates, return the ZeroRates.

Settle = datenum('01-Feb-2013');

CurveDates = [datenum('01-Feb-2014')
    datenum('01-Feb-2015')
    datenum('01-Feb-2016')
    datenum('01-Feb-2018')
    datenum('01-Feb-2020')
    datenum('01-Feb-2023')
    datenum('01-Feb-2033')
    datenum('01-Feb-2043')];

OriginalParRates = [0.11 0.30 0.64 1.42 2.02 2.51 3.10 3.31]'/100;

InputCompounding = 1;
InputBasis = 0;
OutputCompounding = 1;
OutputBasis = 0;

ZeroRates = pyld2zero(OriginalParRates, CurveDates, Settle, ...
'OutputCompounding', OutputCompounding, 'OutputBasis', OutputBasis, ...
'InputCompounding', InputCompounding, 'InputBasis', InputBasis)
ZeroRates =

    0.0011
    0.0030
    0.0064
    0.0144
    0.0207
    0.0261
    0.0329
    0.0356

Using the ZeroRates, use the zero2pyld function to return the ParRatesOut and determine the roundtrip error.

ParRatesOut = zero2pyld(ZeroRates, CurveDates, Settle, ...
'OutputCompounding', OutputCompounding, 'OutputBasis', OutputBasis, ...
'InputCompounding', InputCompounding, 'InputBasis', InputBasis)

max(abs(OriginalParRates - ParRatesOut)) % Roundtrip error
ParRatesOut =

    0.0011
    0.0030
    0.0064
    0.0142
    0.0202
    0.0251
    0.0310
    0.0331


ans =

   1.2750e-16

Related Examples

See Also

|

Introduced before R2006a

Was this topic helpful?