This function creates a Yield curve which defined by a set of quotes of prices of (potentially heterogeneous) market instruments maturing at different dates. See also Live Running Example and online view-only spreadsheet.
Usage:
=qlPiecewiseYieldCurve(<ObjPrefix>, <NDays>, <Calendar>,
<RateHelpers>, <DayCounter>,
<Jumps>, <JumpDates>,
<Accuracy>, <TraitsID>,
<InterpolatorID>)
Optional prefix for names of objects created with this function
Number of dates from the EvaluationDate at which the discount factor is 1.0, i.e., number of days to the value date of the curve
The calendar used for determining the business days. For example, “TARGET” (see TARGET Calendar)
Sequence of “Rate Helpers” (see “Rate Helpers” in QuantLib) that encapsulate the market information about the yield curve
Day count convention used to calculate the interest earned over a specific period of time (see Day Count(ing) Conventions). For example, “Actual/360”.
A sequence of values representing discontinuities in the yield curve. The JumpDates parameter specifies the associated dates of these discontinuities
Sequence of dates at which the yield curve is discontinuous. The parameter <Jumps> specifies the size of the discontinuity.
Optional accuracy for which the iterative bootstrap process should aim for.
A string specifying the type of the curve that will be
create. Possible values are Discount
, ZeroYield
, or ForwardRate
. The corresponding quantity is interpolated along the curve.
Type of interpolation to do between the implied rates. Possible
values are BackwardFlat
, ForwardFlat
, Linear
,
LogLinear
, LogParabolic
, KrugerLogCubic
,
MonotonicLogCubicNaturalSpline
. See also
Interpolation in QuantLib
This is a very simple example that demonstrates building a yield curve
based on quotes on two EONIA swaps. The function qlYieldTSDiscount
is then used to extract the discount factor at three months implied by
the curve.
=qlEonia(“EONIAIndx”) |
-> |
EONIAIndx#0000 |
=qlOISRateHelper(“OIS1M”, 2, “1M”,0.01,R[-1]C) |
-> |
OIS1M#0003 |
=qlOISRateHelper(“OIS6M”, 2, “6M”,0.01,R[-2]C) |
-> |
OIS6M#0001 |
=qlPiecewiseYieldCurve(“YC”, 2, “TARGET”,R[-2]C:R[-1]C, “ACT/360”, ,,,”Discount”, “ForwardFlat”) |
-> |
YC#0001 |
=qlYieldTSDiscount(R[-1]C,”3M”) |
-> |
0.999112 |
Here is example usage in QLW – QuantLib-Addin like interface from Java and Python
// Copyright (C) 2012 Bojan Nikolic <bojan@bnikolic.co.uk>
//
import co.uk.bnikolic.qlw.property_t;
import co.uk.bnikolic.qlw.qlw;
import co.uk.bnikolic.qlw.StringVector;
import co.uk.bnikolic.qlw.LongVector;
import co.uk.bnikolic.qlw.PropertyVector;
import co.uk.bnikolic.qlw.DoubleVector;
public class qlPiecewiseYieldCurve {
public static void main(String[] args) throws Exception {
StringVector helpers=new StringVector();
helpers.add(mkOISHelp("1M", 0.02));
helpers.add(mkOISHelp("6M", 0.2));
property_t dcc=new property_t("Actual/365 (Fixed)");
String yc=qlw.qlPiecewiseYieldCurve("yc",
new property_t(2),
"TARGET",
helpers,
dcc,
new PropertyVector(),
new PropertyVector(),
new property_t(0.0001),
new property_t("Discount"),
new property_t("ForwardFlat"));
PropertyVector periods=new PropertyVector();
for(int i=1; i<5; ++i)
{
periods.add(new property_t((i)+"M"));
}
DoubleVector discounts=qlw.qlYieldTSDiscount(yc,
periods,
qlw.OH_NULL());
for(int i=0; i<discounts.size(); ++i)
{
System.out.println("Discount at " + qlw.OH_GetString(periods.get(i)) +
" is: " + discounts.get(i));
}
}
public static String mkOISHelp(String term, double rate)
{
String index=qlw.qlEonia("eonia"+term,
qlw.OH_NULL());
String oishelp=qlw.qlOISRateHelper("OISHelp"+term,
2,
term,
new property_t(rate),
index,
qlw.OH_NULL());
return oishelp;
}
}
The following example shows piecewise curve bootstrapped from OIS (see qlOISRateHelper – create a Rate Helper referencing an overnight index swap) data.
# Copyright (C) 2012-2018 Bojan Nikolic <bojan@bnikolic.co.uk>
from qlww import *
def mkOISHelp(term, rate):
index=qlEonia("eonia"+term,
N());
oishelp=qlOISRateHelper("OISHelp"+term,
2,
term,
property_t(rate),
index,
N() );
return oishelp;
helpers=StringVector()
helpers.push_back(mkOISHelp("1M", 0.2))
helpers.push_back(mkOISHelp("3M", 0.2))
helpers.push_back(mkOISHelp("6M", 0.5))
helpers.push_back(mkOISHelp("12M", 0.5))
dcc=P("Actual/365 (Fixed)");
yc=qlPiecewiseYieldCurve(UU("yc"),
P(2),
"TARGET",
helpers,
dcc,
PropertyVector(),
PropertyVector(),
P(0.0001),
P("ZeroYield"),
P("ForwardFlat"))
periods=[str(i)+"M" for i in range(1,12)]
discounts=qlYieldTSDiscount(yc,
PropV(periods),
N())
for i in range(len(discounts)):
print("Discount at " + periods[i] +
" is: " + str(discounts[i]))