QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mchestonhullwhiteengine.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007, 2008 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#include <ql/pricingengines/vanilla/mchestonhullwhiteengine.hpp>
25#include <utility>
26
27namespace QuantLib {
28
30 Time exerciseTime,
31 ext::shared_ptr<Payoff> payoff,
32 ext::shared_ptr<HybridHestonHullWhiteProcess> process)
33 : exerciseTime_(exerciseTime), payoff_(std::move(payoff)), process_(std::move(process)) {}
34
36 QL_REQUIRE(path.pathSize() > 0, "the path cannot be empty");
37
38 Array states(path.assetNumber());
39 for (Size j=0; j < states.size(); ++j) {
40 states[j] = path[j][path.pathSize()-1];
41 }
42
43 const DiscountFactor df(
44 1.0/process_->numeraire(exerciseTime_, states));
45 return (*payoff_)(states[0])*df;
46 }
47}
48
1-D array used in linear algebra.
Definition: array.hpp:52
Size size() const
dimension of the array
Definition: array.hpp:495
HestonHullWhitePathPricer(Time exerciseTime, ext::shared_ptr< Payoff > payoff, ext::shared_ptr< HybridHestonHullWhiteProcess > process)
Real operator()(const MultiPath &path) const override
ext::shared_ptr< HybridHestonHullWhiteProcess > process_
Correlated multiple asset paths.
Definition: multipath.hpp:39
Size pathSize() const
Definition: multipath.hpp:48
Size assetNumber() const
Definition: multipath.hpp:47
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
STL namespace.