QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mc_discr_arith_av_price_heston.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 This file is part of QuantLib, a free-software/open-source library
5 for financial quantitative analysts and developers - http://quantlib.org/
6
7 QuantLib is free software: you can redistribute it and/or modify it
8 under the terms of the QuantLib license. You should have received a
9 copy of the license along with this program; if not, please email
10 <quantlib-dev@lists.sf.net>. The license is also available online at
11 <http://quantlib.org/license.shtml>.
12
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18#include <ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp>
19#include <utility>
20
21namespace QuantLib {
22
24 Real strike,
25 DiscountFactor discount,
26 std::vector<Size> fixingIndices,
27 Real runningSum,
28 Size pastFixings)
29 : payoff_(type, strike), discount_(discount), fixingIndices_(std::move(fixingIndices)),
30 runningSum_(runningSum), pastFixings_(pastFixings) {
31 QL_REQUIRE(strike>=0.0,
32 "strike less than zero not allowed");
33 }
34
36 const Path& path = multiPath[0];
37 const Size n = multiPath.pathSize();
38 QL_REQUIRE(n>0, "the path cannot be empty");
39
40 Real sum = runningSum_;
41 Size fixings = pastFixings_ + fixingIndices_.size();
42
43 for (unsigned long fixingIndice : fixingIndices_) {
44 sum += path[fixingIndice];
45 }
46
47 Real averagePrice = sum/fixings;
48 return discount_ * payoff_(averagePrice);
49 }
50
51}
ArithmeticAPOHestonPathPricer(Option::Type type, Real strike, DiscountFactor discount, std::vector< Size > fixingIndices, Real runningSum=0.0, Size pastFixings=0)
Real operator()(const MultiPath &multiPath) const override
Correlated multiple asset paths.
Definition: multipath.hpp:39
Size pathSize() const
Definition: multipath.hpp:48
single-factor random walk
Definition: path.hpp:40
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.