Bojan Nikolic: Using and Understanding the QuantLib Addin

[website home] | [BN Algorithms]

qlInterpolatedYieldCurve – Create a yield curve that interpolates between supplied data

Usage:

=qlInterpolatedYieldCurve(<ObjPrefix>,
                          <Dates>,  <Data>,
                          <Calendar>, <DayCounter>,
                          <Jumps>, <JumpDates>,
                          <TraitsID>, <InterpolatorID>)
<ObjPrefix>

Usual meaning

<Dates>

Sequence of dates for at which <Data> apply at. The dates can either be absolute, i.e., in the Excel date convention, or they can be relative dates such as “1D”, “3M”, “1Y”, etc.

<Data>

Sequence of data corresponding to the supplied dates. These data are used to form the curve and are interpreted based on the value of the <TraitsID> parameter.

<Calendar>

The calendar used for determining the business days. For example, “TARGET” (see TARGET Calendar)

<DayCounter>

Day count convention used to calculate the interest earned over a specific period of time. For example, “Actual/360”.

<Jumps>

A sequence of values representing discontinuities in the yield curve. The JumpDates parameter specifies the associated dates of these discontinuities

<JumpDates>

Sequence of dates at which the yield curve is discontinuous. The parameter <Jumps> specifies the size of the discontinuity.

<TraitsID>

A string specifying the type of data that has been supplied to the function. Possible values are Discount, ZeroYield, or ForwardRate

<InterpolatorID>

Type of interpolation to do between the supplied data. Possible values are BackwardFlat, ForwardFlat, Linear, LogLinear, LogParabolic, KrugerLogCubic, MonotonicLogCubicNaturalSpline. See also Interpolation in QuantLib

Example

This is the simplest possible example that builds an interpolated curve with only two points which are specified by relative dates (“0D” is today, and “1Y” is one year from now). The data are supplied as “Zero” yields of 1%.

0D

0.01

->

0D

0.01

1Y

0.01

->

1Y

0.01

=qlInterpolatedYieldCurve(,R[-2]C:R[-1]C,R[-2]C[1]:R[-1]C[1],”Target”, “Actual/360”, ,,”ZeroYield”,)

Yield Curve Object

->

obj_00009#0004

Yield Curve Object

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 qlInterpolatedYieldCurve {
    
    public static void main(String[] args) throws Exception {

        PropertyVector datesList= new PropertyVector();
        datesList.add(new property_t("0D"));
        datesList.add(new property_t("1Y"));
        DoubleVector ratesList=new DoubleVector();
        ratesList.add(0.01);
        ratesList.add(0.01);

        property_t dcc=new property_t("Actual/365 (Fixed)");
        
        String curve=qlw.qlInterpolatedYieldCurve("curve",
                                                  datesList,  
                                                  ratesList,
                                                  "TARGET", dcc,
                                                  new PropertyVector(), 
                                                  new PropertyVector(),
                                                  new property_t("ZeroYield"), 
                                                  new property_t("LogLinear"),
                                                  qlw.OH_NULL(),
                                                  qlw.OH_NULL(),
                                                  false);
        
    }

}