QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
marketmodel.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) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2006, 2007 Mark Joshi
6 Copyright (C) 2007 StatPro Italia srl
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22
23#ifndef quantlib_marketmodel_hpp
24#define quantlib_marketmodel_hpp
25
26#include <ql/math/matrix.hpp>
27#include <ql/utilities/null.hpp>
29#include <vector>
30
31namespace QuantLib {
32
33 class EvolutionDescription;
34
35 //! base class for market models
36 /*! For each time step, generates the pseudo-square root of the covariance
37 matrix for that time step.
38 */
40 public:
41 virtual ~MarketModel() = default;
42 virtual const std::vector<Rate>& initialRates() const = 0;
43 virtual const std::vector<Spread>& displacements() const = 0;
44 virtual const EvolutionDescription& evolution() const = 0;
45 virtual Size numberOfRates() const = 0;
46 virtual Size numberOfFactors() const = 0;
47 virtual Size numberOfSteps() const = 0;
48 virtual const Matrix& pseudoRoot(Size i) const = 0;
49 virtual const Matrix& covariance(Size i) const;
50 virtual const Matrix& totalCovariance(Size endIndex) const;
51 std::vector<Volatility> timeDependentVolatility(Size i) const;
52 private:
53 mutable std::vector<Matrix> covariance_, totalCovariance_;
54 };
55
56 //! base class for market-model factories
58 public:
59 ~MarketModelFactory() override = default;
60 virtual ext::shared_ptr<MarketModel> create(
62 Size numberOfFactors) const = 0;
63 };
64
65
66}
67
68#endif
Market-model evolution description.
base class for market-model factories
Definition: marketmodel.hpp:57
virtual ext::shared_ptr< MarketModel > create(const EvolutionDescription &, Size numberOfFactors) const =0
~MarketModelFactory() override=default
base class for market models
Definition: marketmodel.hpp:39
std::vector< Volatility > timeDependentVolatility(Size i) const
Definition: marketmodel.cpp:55
virtual const Matrix & covariance(Size i) const
Definition: marketmodel.cpp:28
virtual Size numberOfFactors() const =0
std::vector< Matrix > totalCovariance_
Definition: marketmodel.hpp:53
virtual ~MarketModel()=default
virtual const Matrix & totalCovariance(Size endIndex) const
Definition: marketmodel.cpp:40
std::vector< Matrix > covariance_
Definition: marketmodel.hpp:53
virtual const std::vector< Rate > & initialRates() const =0
virtual const Matrix & pseudoRoot(Size i) const =0
virtual Size numberOfSteps() const =0
virtual const EvolutionDescription & evolution() const =0
virtual const std::vector< Spread > & displacements() const =0
virtual Size numberOfRates() const =0
Matrix used in linear algebra.
Definition: matrix.hpp:41
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
std::size_t Size
size of a container
Definition: types.hpp:58
matrix used in linear algebra.
Definition: any.hpp:35
null values
observer/observable pattern