C++

Swap Valuation

Posted on

/*! Swap Valuation */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* This example shows how to set up a Term Structure and then price a simple swap. */ // the only header you need to use QuantLib #include <ql/quantlib.hpp> #ifdef BOOST_MSVC /* Uncomment the following lines to unmask floating-point […]

C++

Repo

Posted on

/*! Repo */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* a Repo calculation done using the FixedRateBondForward class cf. aaBondFwd() repo example at http://www.fincad.com/support/developerFunc/mathref/BFWD.htm This repo is set up to use the repo rate to do all discounting (including the underlying bond income). Forward delivery price is also obtained […]

C++

Replication

Posted on

/*! Replication */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* This example showcases the CompositeInstrument class. Such class is used to build a static replication of a down-and-out barrier option, as outlined in Section 10.2 of Mark Joshi’s “The Concepts and Practice of Mathematical Finance” to which we refer […]

C++

Multidimensional Integral

Posted on

/*! Multidimensional Integral */ #include <iostream> #include <iomanip> #include <boost/function.hpp> #include <boost/timer.hpp> #include <ql/quantlib.hpp> using namespace QuantLib; using namespace std; #ifdef BOOST_MSVC # ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN # include <ql/auto_link.hpp> # define BOOST_LIB_NAME boost_system # include <boost/config/auto_link.hpp> # undef BOOST_LIB_NAME # define BOOST_LIB_NAME boost_thread # include <boost/config/auto_link.hpp> # undef BOOST_LIB_NAME # endif #endif #if defined(QL_ENABLE_SESSIONS) namespace QuantLib […]

C++

Market Models

Posted on

/*! Market Models */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <ql/qldefines.hpp> #include <ql/version.hpp> #ifdef BOOST_MSVC # include <ql/auto_link.hpp> #endif #include <ql/models/marketmodels/all.hpp> #include <ql/methods/montecarlo/genericlsregression.hpp> #include <ql/legacy/libormarketmodels/lmlinexpcorrmodel.hpp> #include <ql/legacy/libormarketmodels/lmextlinexpvolmodel.hpp> #include <ql/time/schedule.hpp> #include <ql/time/calendars/nullcalendar.hpp> #include <ql/time/daycounters/simpledaycounter.hpp> #include <ql/pricingengines/blackformula.hpp> #include <ql/pricingengines/blackcalculator.hpp> #include <ql/utilities/dataformatters.hpp> #include <ql/math/integrals/segmentintegral.hpp> #include <ql/math/statistics/convergencestatistics.hpp> #include <ql/termstructures/volatility/abcd.hpp> #include <ql/termstructures/volatility/abcdcalibration.hpp> #include […]

C++

Latent Model

Posted on

/* Latent Model */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <ql/quantlib.hpp> #include <boost/timer.hpp> #include <boost/make_shared.hpp> #include <boost/function.hpp> #include <iostream> #include <iomanip> using namespace std; using namespace QuantLib; #ifdef BOOST_MSVC # ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN # include <ql/auto_link.hpp> # define BOOST_LIB_NAME boost_system # include <boost/config/auto_link.hpp> # undef BOOST_LIB_NAME # define BOOST_LIB_NAME […]

C++

Gaussian 1_dim Models

Posted on

/* Gaussian 1-Dimensional Models */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <ql/quantlib.hpp> #include <boost/timer.hpp> using namespace QuantLib; #ifdef BOOST_MSVC # ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN # include <ql/auto_link.hpp> # define BOOST_LIB_NAME boost_system # include <boost/config/auto_link.hpp> # undef BOOST_LIB_NAME # define BOOST_LIB_NAME boost_thread # include <boost/config/auto_link.hpp> # undef BOOST_LIB_NAME # endif #endif […]

C++

FRA

Posted on

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! FRA */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* This example shows how to set up a term structure and price a simple forward-rate agreement. */ // the only header you need to use QuantLib #include […]

C++

Fitted Bond Curve

Posted on

/*! Fitted Bond Curve */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* This example shows how to fit a term structure to a set of bonds using four different fitting methodologies. Though fitting is most useful for large numbers of bonds with non-smooth yield tenor structures, for comparison purposes, […]

C++

Equity Option

Posted on

/*! Equity Option */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // the only header you need to use QuantLib #include <ql/quantlib.hpp> #ifdef BOOST_MSVC /* Uncomment the following lines to unmask floating-point exceptions. Warning: unpredictable results can arise… See http://www.wilmott.com/messageview.cfm?catid=10&threadid=9481 */ // #include <float.h> // namespace { unsigned int u […]