Bojan Nikolic: Using and Understanding the QuantLib Addin

[website home] | [BN Algorithms]

qlBlackSwaptionEngine – Create a Swaption Valuation Engine

Usage:

=qlBlackSwaptionEngine(<ObjPrefix>, <YieldCurve>,
                       <VolTS>)
<ObjPrefix>

Optional prefix for names of objects created with this function

<YieldCurve>

Yield curve object to be used for discounting the cashflows. See for example qlInterpolatedYieldCurve – Create a yield curve that interpolates between supplied data

<VolTS>

Object representing the interest rate volatility. See for example qlConstantSwaptionVolatility – Simple rates volatility for use with swaptions

// 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 qlBlackSwaptionEngine {
    
    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);

        String vol=qlw.qlConstantSwaptionVolatility("vol",
                                                    new property_t(0),
                                                    "TARGET",
                                                    "Following",
                                                    new property_t(0.20),
                                                    new property_t("Actual/365 (Fixed)"),
                                                    qlw.OH_NULL(),
                                                    qlw.OH_NULL(),
                                                    false);

        String engine=qlw.qlBlackSwaptionEngine("engine",
                                                curve, vol, 
                                                qlw.OH_NULL(),
                                                qlw.OH_NULL(),
                                                false);
    }

}