QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
adaptedpathpayoff.hpp
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) 2009 Andrea Odetti
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
20/*! \file adaptedpathpayoff.hpp
21 \brief Adapted Option payoff classes
22*/
23
24#ifndef quantlib_adapted_path_payoff_hpp
25#define quantlib_adapted_path_payoff_hpp
26
28
29namespace QuantLib {
30
32 public:
33
35 public:
36 Size numberOfTimes() const;
37 Size numberOfAssets() const;
38
39 Real getAssetValue(Size time, Size asset);
40
42
43 void setPayoffValue(Size time, Real value);
44
45 // set the exercise payoff if the option is exercised at time "time"
46 // it destroys state
47 void setExerciseData(Size time, Real exercise, Array & state);
48
49 private:
50
51 friend class AdaptedPathPayoff;
52
53 ValuationData(const Matrix & path,
54 const std::vector<Handle<YieldTermStructure> > & forwardTermStructures,
55 Array & payments,
56 Array & exercises,
57 std::vector<Array> & states);
58
59 const Matrix & path_;
60 const std::vector<Handle<YieldTermStructure> > & forwardTermStructures_;
61
64 std::vector<Array> & states_;
65
67 };
68
69 void value(const Matrix& path,
70 const std::vector<Handle<YieldTermStructure> >& forwardTermStructures,
71 Array& payments,
72 Array& exercises,
73 std::vector<Array>& states) const override;
74
75 protected:
76
77 /*
78 Key method of this class.
79
80 It computes the payoff by calling ValuationData::setPayoffValue();
81 and provides early exercise information
82 via ValuationData::setExerciseData();
83 */
84 virtual void operator()(ValuationData & data) const = 0;
85 };
86}
87
88#endif
void setExerciseData(Size time, Real exercise, Array &state)
const Handle< YieldTermStructure > & getYieldTermStructure(Size time)
const std::vector< Handle< YieldTermStructure > > & forwardTermStructures_
virtual void operator()(ValuationData &data) const =0
void value(const Matrix &path, const std::vector< Handle< YieldTermStructure > > &forwardTermStructures, Array &payments, Array &exercises, std::vector< Array > &states) const override
1-D array used in linear algebra.
Definition: array.hpp:52
Shared handle to an observable.
Definition: handle.hpp:41
Matrix used in linear algebra.
Definition: matrix.hpp:41
Abstract base class for path-dependent option payoffs.
Definition: pathpayoff.hpp:36
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
Option payoff classes.