QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
normalclvmodel.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) 2016 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
20/*! \file normalclvmodel.hpp
21 \brief CLV model with a normally distributed kernel process
22*/
23
24#ifndef quantlib_normal_clv_model_hpp
25#define quantlib_normal_clv_model_hpp
26
30#include <ql/math/matrix.hpp>
31#include <ql/time/date.hpp>
32#include <ql/functional.hpp>
33
34namespace QuantLib {
35 /*! References:
36
37 A. Grzelak, 2016, The CLV Framework -
38 A Fresh Look at Efficient Pricing with Smile
39
40 http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2747541
41 */
42
43 class PricingEngine;
44 class GBSMRNDCalculator;
45 class OrnsteinUhlenbeckProcess;
46 class GeneralizedBlackScholesProcess;
47
48 class NormalCLVModel : public LazyObject {
49 public:
50 NormalCLVModel(const ext::shared_ptr<GeneralizedBlackScholesProcess>& bsProcess,
51 ext::shared_ptr<OrnsteinUhlenbeckProcess> ouProcess,
52 const std::vector<Date>& maturityDates,
53 Size lagrangeOrder,
54 Real pMax = Null<Real>(),
55 Real pMin = Null<Real>());
56
57 // cumulative distribution function of the BS process
58 Real cdf(const Date& d, Real x) const;
59
60 // inverse cumulative distribution function of the BS process
61 Real invCDF(const Date& d, Real q) const;
62
63 // collocation points of the Ornstein-Uhlenbeck process
64 Array collocationPointsX(const Date& d) const;
65
66 // collocation points for the underlying Y
67 Array collocationPointsY(const Date& d) const;
68
69 // CLV mapping function
70 ext::function<Real(Time, Real)> g() const;
71
72 protected:
73 void performCalculations() const override;
74
75 private:
77 public:
78 explicit MappingFunction(const NormalCLVModel& model);
79
80 Real operator()(Time t, Real x) const;
81
82 private:
83 mutable Array y_;
85 const ext::shared_ptr<OrnsteinUhlenbeckProcess> ouProcess_;
86
88 explicit InterpolationData(const NormalCLVModel& model)
89 : s_(model.x_.size(), model.maturityDates_.size()),
90 x_(model.x_),
91 t_(model.maturityTimes_),
92 lagrangeInterpl_(x_.begin(), x_.end(), x_.begin()) {}
93
95 std::vector<LinearInterpolation> interpl_;
96
97 const Array x_;
98 const std::vector<Time> t_;
100 };
101
102 const ext::shared_ptr<InterpolationData> data_;
103 };
104
105
106 const Array x_;
108 const ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
109 const ext::shared_ptr<OrnsteinUhlenbeckProcess> ouProcess_;
110 const std::vector<Date> maturityDates_;
111 const ext::shared_ptr<GBSMRNDCalculator> rndCalculator_;
112
113 std::vector<Time> maturityTimes_;
114 mutable ext::function<Real(Time, Real)> g_;
115 };
116}
117
118#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Concrete date class.
Definition: date.hpp:125
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
Matrix used in linear algebra.
Definition: matrix.hpp:41
const ext::shared_ptr< InterpolationData > data_
const ext::shared_ptr< OrnsteinUhlenbeckProcess > ouProcess_
const std::vector< Date > maturityDates_
void performCalculations() const override
std::vector< Time > maturityTimes_
const ext::shared_ptr< GeneralizedBlackScholesProcess > bsProcess_
Real invCDF(const Date &d, Real q) const
Real cdf(const Date &d, Real x) const
ext::function< Real(Time, Real)> g_
const ext::shared_ptr< OrnsteinUhlenbeckProcess > ouProcess_
const ext::shared_ptr< GBSMRNDCalculator > rndCalculator_
Array collocationPointsX(const Date &d) const
Array collocationPointsY(const Date &d) const
ext::function< Real(Time, Real)> g() const
template class providing a null value for a given type.
Definition: null.hpp:76
date- and time-related classes, typedefs and enumerations
const DefaultType & t
Date d
Maps function, bind and cref to either the boost or std implementation.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
std::size_t Size
size of a container
Definition: types.hpp:58
framework for calculation on demand and result caching
linear interpolation between discrete points
matrix used in linear algebra.
Definition: any.hpp:35
ext::shared_ptr< YieldTermStructure > q