C++

CVA_IRS

Posted on

/* CVA IRS */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <ql/quantlib.hpp> #include <boost/timer.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 boost_thread # include <boost/config/auto_link.hpp> […]

C++

Convertible Bonds

Posted on

/*! Convertible bonds */ /* -*- 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 […]

C++

CDS

Posted on

/* CDS */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <ql/quantlib.hpp> #include <boost/timer.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 boost_thread # include <boost/config/auto_link.hpp> # […]

C++

Callable Bonds

Posted on

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! Callable Bonds */ /* This example sets up a callable fixed rate bond with a Hull White pricing engine and compares to Bloomberg’s Hull White price/yield calculations. */ #ifdef BOOST_MSVC /* Uncomment the following lines to unmask floating-point exceptions. Warning: unpredictable results […]

C++

Bonds

Posted on

/*! Bonds */ /* -*- 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 some simple bonds. The last part is dedicated to peripherical computations such as “Yield to Price” or “Price to Yield” */ // the only header you […]

C++

Bermudan Swaption

Posted on

/*! Bermudan Swaption */ /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #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 = _controlfp(_EM_INEXACT, _MCW_EM); } #endif #include <boost/timer.hpp> #include <iostream> […]

C++

Basket Losses

Posted on

  /* Basket Losses */ /* -*- 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 <boost/assign/std/vector.hpp> #include <iostream> #include <iomanip> using namespace std; using namespace QuantLib; using namespace boost::assign; #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> […]

R Studio

Hull_White_Calibration

Posted on

## model – # Define the Model Parameters for a Heston-Nandi Option: model = list(lambda = -0.5, omega = 2.3e-6, alpha = 2.9e-6, beta = 0.85, gamma = 184.25) S = X = 100 Time.inDays = 252 r.daily = 0.05/Time.inDays sigma.daily = sqrt((model$omega + model$alpha) / (1 – model$beta – model$alpha * model$gamma^2)) data.frame(S, X, […]

R Studio

Heston Nandi Garch_Greeks

Posted on

## model – # Define the Model Parameters for a Heston-Nandi Option: model = list(lambda = -0.5, omega = 2.3e-6, alpha = 2.9e-6, beta = 0.85, gamma = 184.25) S = X = 100 Time.inDays = 252 r.daily = 0.05/Time.inDays sigma.daily = sqrt((model$omega + model$alpha) / (1 – model$beta – model$alpha * model$gamma^2)) data.frame(S, X, […]

R Studio

Heston Nandi Garch

Posted on

## hngarchSim – # Simulate a Heston Nandi Garch(1,1) Process: # Symmetric Model – Parameters: model = list(lambda = 4, omega = 8e-5, alpha = 6e-5, beta = 0.7, gamma = 0, rf = 0) ts = hngarchSim(model = model, n = 500, n.start = 100) par(mfrow = c(2, 1), cex = 0.75) ts.plot(ts, col […]