QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
squarerootclvmodel.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 squarerootclvmodel.hpp
21 \brief CLV model with a square root kernel process
22*/
23
24#ifndef quantlib_square_root_clv_model_hpp
25#define quantlib_square_root_clv_model_hpp
26
27#include <ql/time/date.hpp>
30#include <ql/math/matrix.hpp>
32#include <ql/functional.hpp>
33#include <map>
34
35namespace QuantLib {
36
37 class GBSMRNDCalculator;
38 class SquareRootProcess;
39 class GeneralizedBlackScholesProcess;
40
42 public:
43 SquareRootCLVModel(const ext::shared_ptr<GeneralizedBlackScholesProcess>& bsProcess,
44 ext::shared_ptr<SquareRootProcess> sqrtProcess,
45 std::vector<Date> maturityDates,
46 Size lagrangeOrder,
47 Real pMax = Null<Real>(),
48 Real pMin = Null<Real>());
49
50 // cumulative distribution function of the BS process
51 Real cdf(const Date& d, Real x) const;
52
53 // inverse cumulative distribution function of the BS process
54 Real invCDF(const Date& d, Real q) const;
55
56 // collocation points of the square root process
57 Array collocationPointsX(const Date& d) const;
58
59 // collocation points for the underlying Y
60 Array collocationPointsY(const Date& d) const;
61
62 // CLV mapping function
63 ext::function<Real(Time, Real)> g() const;
64
65 protected:
66 void performCalculations() const override;
67
68 private:
70 public:
71 explicit MappingFunction(const SquareRootCLVModel& model);
72
73 Real operator()(Time t, Real x) const;
74
75 private:
76 const ext::shared_ptr<Matrix> s_, x_;
77 typedef std::map<Time, ext::shared_ptr<LagrangeInterpolation> >
79
81 };
82
83 std::pair<Real, Real> nonCentralChiSquaredParams(const Date& d) const;
84
86 const ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
87 const ext::shared_ptr<SquareRootProcess> sqrtProcess_;
88 const std::vector<Date> maturityDates_;
90 const ext::shared_ptr<GBSMRNDCalculator> rndCalculator_;
91
92 mutable ext::function<Real(Time, Real)> g_;
93 };
94}
95
96#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
template class providing a null value for a given type.
Definition: null.hpp:76
std::map< Time, ext::shared_ptr< LagrangeInterpolation > > interpl_type
const std::vector< Date > maturityDates_
void performCalculations() const override
const ext::shared_ptr< GeneralizedBlackScholesProcess > bsProcess_
const ext::shared_ptr< SquareRootProcess > sqrtProcess_
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< GBSMRNDCalculator > rndCalculator_
std::pair< Real, Real > nonCentralChiSquaredParams(const Date &d) const
Array collocationPointsX(const Date &d) const
Array collocationPointsY(const Date &d) const
ext::function< Real(Time, Real)> g() const
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.
non central chi squared polynomials for Gaussian quadratures
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
framework for calculation on demand and result caching
matrix used in linear algebra.
Definition: any.hpp:35
ext::shared_ptr< YieldTermStructure > q