QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
analytichestonhullwhiteengine.cpp
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
21#include <ql/pricingengines/vanilla/analytichestonhullwhiteengine.hpp>
22#include <utility>
23
24namespace QuantLib {
25
27 const ext::shared_ptr<HestonModel>& hestonModel,
28 ext::shared_ptr<HullWhite> hullWhiteModel,
29 Size integrationOrder)
30 : AnalyticHestonEngine(hestonModel, integrationOrder),
31 hullWhiteModel_(std::move(hullWhiteModel)) {
34 }
35
37 const ext::shared_ptr<HestonModel>& hestonModel,
38 ext::shared_ptr<HullWhite> hullWhiteModel,
39 Real relTolerance,
40 Size maxEvaluations)
41 : AnalyticHestonEngine(hestonModel, relTolerance, maxEvaluations),
42 hullWhiteModel_(std::move(hullWhiteModel)) {
45 }
46
50 }
51
53
54 const Real t = model_->process()->time(arguments_.exercise->lastDate());
55 if (a_*t > std::pow(QL_EPSILON, 0.25)) {
56 m_ = sigma_*sigma_/(2*a_*a_)
57 *(t+2/a_*std::exp(-a_*t)-1/(2*a_)*std::exp(-2*a_*t)-3/(2*a_));
58 }
59 else {
60 // low-a algebraic limit
61 m_ = 0.5*sigma_*sigma_*t*t*t*(1/3.0-0.25*a_*t+7/60.0*a_*a_*t*t);
62 }
63
65 }
66
68 a_ = hullWhiteModel_->params()[0];
69 sigma_ = hullWhiteModel_->params()[1];
70 }
71
72}
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_
virtual void update()=0
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
#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.