QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
analytichestonhullwhiteengine.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Klaus Spanderen
5 Copyright (C) 2007 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
22#include <utility>
23
24namespace QuantLib {
25
27 const ext::shared_ptr<HestonModel>& hestonModel,
28 ext::shared_ptr<HullWhite> hullWhiteModel,
29 Size integrationOrder)
31 hestonModel, AnalyticHestonEngine::Gatheral,
32 AnalyticHestonEngine::Integration::gaussLaguerre(integrationOrder)),
33 hullWhiteModel_(std::move(hullWhiteModel)) {
36 }
37
39 const ext::shared_ptr<HestonModel>& hestonModel,
40 ext::shared_ptr<HullWhite> hullWhiteModel,
41 Real relTolerance,
42 Size maxEvaluations)
44 hestonModel, AnalyticHestonEngine::Gatheral,
45 AnalyticHestonEngine::Integration::gaussLobatto(
46 relTolerance, Null<Real>(), maxEvaluations)),
47 hullWhiteModel_(std::move(hullWhiteModel)) {
50 }
51
55 }
56
58
59 const Real t = model_->process()->time(arguments_.exercise->lastDate());
60 if (a_*t > std::pow(QL_EPSILON, 0.25)) {
61 m_ = sigma_*sigma_/(2*a_*a_)
62 *(t+2/a_*std::exp(-a_*t)-1/(2*a_)*std::exp(-2*a_*t)-3/(2*a_));
63 }
64 else {
65 // low-a algebraic limit
66 m_ = 0.5*sigma_*sigma_*t*t*t*(1/3.0-0.25*a_*t+7/60.0*a_*a_*t*t);
67 }
68
70 }
71
73 a_ = hullWhiteModel_->params()[0];
74 sigma_ = hullWhiteModel_->params()[1];
75 }
76
77}
analytic heston engine incl. stochastic interest rates
analytic Heston-model engine based on Fourier transform
AnalyticHestonHullWhiteEngine(const ext::shared_ptr< HestonModel > &hestonModel, ext::shared_ptr< HullWhite > hullWhiteModel, Size integrationOrder=144)
const ext::shared_ptr< HullWhite > hullWhiteModel_
template class providing a null value for a given type.
Definition: null.hpp:76
virtual void update()=0
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
const DefaultType & t
#define QL_EPSILON
Definition: qldefines.hpp:178
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
STL namespace.