Bojan Nikolic: Using and Understanding the QuantLib Addin

[website home] | [BN Algorithms]

TARGET Calendar

TARGET is an acronym for the Trans-European Automated Real-time Gross settlement Express Transfer. The associated calendar is used by the ECB [1] and many European market participants.

It is represented in the QuantLib Addin as “TARGET”.

Example

The example below show the use of the qlCalendarAdvance function to calculate the next business day according to the TARGET calendar.

Date Date + 1D Note -> Date Date + 1D Note
2011-12-24 =qlCalendarAdvance(“TARGET”, RC[-1],”1D”) Christmas -> 2011-12-24 2011-12-27 Christmas
2011-12-01 =qlCalendarAdvance(“TARGET”, RC[-1],”1D”) Working Day -> 2011-12-01 2011-12-02 Working Day
2011-12-02 =qlCalendarAdvance(“TARGET”, RC[-1],”1D”) Weekend -> 2011-12-02 2011-12-05 Weekend

Here is example usage in QLW – QuantLib-Addin like interface from Java and Python which shows dates that are 1, 10 and 100 days later according to the TARGET calendar:

// 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.PropertyMatrix;
import co.uk.bnikolic.qlw.DoubleVector;

public class qlSwapLegAnalysis {

    public static void main(String[] args) throws Exception {
        
        String swap=mkSwap();
        PropertyMatrix res=qlw.qlSwapLegAnalysis(swap, 0, qlw.OH_NULL(), qlw.OH_NULL());

        for(int i=0; i<res.size(); ++i)
            {
                if (i==0)
                    {    
                        System.out.print("Header \t");
                    }
                else
                    {
                    System.out.print("Flow #" + i +"\t");
                    }
                for(int j=0; j<res.get(i).size(); ++j)
                    {
                        System.out.print(" " + qlw.OH_GetString((res.get(i)).get(j))+ "\t\t\t");
                    }
                System.out.print("\n");
            }
    }

    // See
    // http://www.bnikolic.co.uk/ql/addindoc/f/qlMakeVanillaSwap.html
    // for explanation of this function
    public static String mkSwap() {
        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);

        String engine=qlw.qlDiscountingSwapEngine("engine", curve,
                                                  qlw.OH_NULL(),
                                                  qlw.OH_NULL(),
                                                  qlw.OH_NULL(),
                                                  qlw.OH_NULL(),
                                                  qlw.OH_NULL(),
                                                  false);

        String index=qlw.qlEuribor("index","6M",
                                   qlw.OH_NULL(),
                                   qlw.OH_NULL(),
                                   qlw.OH_NULL(),
                                   false);

        String swap=qlw.qlMakeVanillaSwap("swap",
                                          "5Y",
                                          index,
                                          new property_t(0.01),
                                          "0D",
                                          new property_t("Actual/360"),
                                          new property_t(0.0),
                                          engine,
                                          qlw.OH_NULL(),
                                          qlw.OH_NULL(),
                                          false);
        return swap;

    }

}
[1]http://www.ecb.int/press/pr/date/2000/html/pr001214_4.en.html