Main Content

pyld2zero

Zero curve given par yield curve

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

Description

example

[ZeroRates,CurveDates] = pyld2zero(ParRates,CurveDates,Settle)返回一个零线投入en a par yield curve and its maturity dates. If either input forCurveDatesorSettleis a datetime array,CurveDatesis returned as a datetime array. Otherwise,CurveDatesis returned as a serial date number.

[ZeroRates,CurveDates] = pyld2zero(___,Name,Value)adds optional name-value pair arguments

Examples

collapse all

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 =8×10.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 =8×10.0011 0.0030 0.0064 0.0144 0.0207 0.0261 0.0329 0.0355

Usedatetimeinputs 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 =8×10.0011 0.0030 0.0064 0.0144 0.0207 0.0261 0.0329 0.0356
日期=8x1 datetime01-Feb-2014 01-Feb-2015 01-Feb-2016 01-Feb-2018 01-Feb-2020 01-Feb-2023 01-Feb-2033 01-Feb-2043

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

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 =8×10.0011 0.0030 0.0064 0.0144 0.0207 0.0261 0.0329 0.0356

With theZeroRates, use thezero2pyldfunction to return theParRatesOutand determine the roundtrip error.

ParRatesOut = zero2pyld(ZeroRates, CurveDates, Settle,...'OutputCompounding', OutputCompounding,'OutputBasis', OutputBasis,...“InputCompounding”, InputCompounding,'InputBasis', InputBasis)
ParRatesOut =8×10.0011 0.0030 0.0064 0.0142 0.0202 0.0251 0.0310 0.0331
max(abs(OriginalParRates - ParRatesOut))% Roundtrip error
ans = 1.2750e-16

Input Arguments

collapse all

Annualized par yields (coupon rates), specified as aNUMBONDS-by-1vector using decimal fractions. In aggregate, the rates constitute an implied zero curve for the investment horizon represented byCurveDates.

Data Types:double

Maturity dates which correspond to the inputParRates, specified as aNUMBONDS-by-1vector using serial date numbers, date character vectors, or datetime arrays.

Data Types:double|datetime|char

Common settlement date for inputParRates, specified as serial date numbers, date character vectors, or datetime arrays.

Data Types:double|datetime|char

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

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

Compounding frequency of outputZeroRates, specified using the allowed values:

  • 0— Simple interest (no compounding)

  • 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

  • -1— Continuous compounding

Note

  • IfOutputCompoundingis set to0(simple),-1(continuous), or365(daily), theInputCompoundingmust also be specified using a valid value.

  • IfOutputCompoundingis not specified, thenOutputCompoundingis assigned the value specified forInputCompounding.

  • If eitherOutputCompoundingorInputCompoundingare not specified, the default is2(semiannual) for both.

Data Types:double

Day count basis of outputZeroRates, specified using allowed 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

For more information, seeBasis.

Note

IfOutputBasisis not specified, thenOutputBasisis assigned the value specified forInputBasis. If eitherInputBasisorOutputBasisare not specified, the default is0(actual/actual) for both.

Data Types:double

Compounding frequency of inputParRates, specified using allowed values:

  • 1— Annual compounding

  • 2— Semiannual compounding (default)

  • 3— Compounding three times per year

  • 4— Quarterly compounding

  • 6— Bimonthly compounding

  • 12— Monthly compounding

Note

  • IfOutputCompoundingis1,2,3,4,6, or12andInputCompoundingis not specified, the value ofOutputCompoundingis used.

  • IfOutputCompoundingis0(simple),-1(continuous), or365(daily), a validInputCompoundingvalue must also be specified.

  • If eitherInputCompoundingorOutputCompoundingare not specified, the default is2(semiannual) for both.

Data Types:double

Day count basis of the inputParRates, specified using allowed 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

For more information, seeBasis.

Note

IfInputBasisis not specified, thenInputBasisis assigned the value specified forOutputBasis. If eitherInputBasisorOutputbasisare not specified, the default is0(actual/actual) for both.

Data Types:double

Output Arguments

collapse all

Zero rates, returned as aNUMBONDS-by-1numeric vector. In aggregate, the rates inZeroRatesconstitute a zero curve for the investment horizon represented byCurveDates.ZeroRatesare ordered by ascending maturity.

Maturity dates that correspond to theZeroRates, returned as aNUMBONDS-by-1vector of maturity dates that correspond to each par rate contained inZeroRates.CurveDatesare ordered by ascending maturity.

If either input forCurveDatesorSettleis a datetime array,CurveDatesis returned as a datetime array. Otherwise,CurveDatesare returned as a serial date numbers.

Introduced before R2006a