QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
compositeproduct.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 StatPro Italia srl
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#ifndef quantlib_market_model_composite_product_hpp
21#define quantlib_market_model_composite_product_hpp
22
26#include <valarray>
27
28namespace QuantLib {
29
30 //! Composition of two or more market-model products
31 /*! Instances of this class build a market-model product by
32 composing one or more subproducts.
33
34 \pre All subproducts must have the same rate times.
35 */
37 public:
39 //! \name MarketModelMultiProduct interface
40 //@{
41 const EvolutionDescription& evolution() const override;
42 std::vector<Size> suggestedNumeraires() const override;
43 std::vector<Time> possibleCashFlowTimes() const override;
44 void reset() override;
45 //@}
46 //! \name Composite facilities
47 //@{
49 Real multiplier = 1.0);
51 Real multiplier = 1.0);
52 void finalize();
53 Size size() const;
54 const MarketModelMultiProduct& item(Size i) const;
56 Real multiplier(Size i) const;
57 //@}
58 protected:
59 // subproducts
60 struct SubProduct {
63 std::vector<Size> numberOfCashflows;
64 std::vector<std::vector<CashFlow> > cashflows;
65 std::vector<Size> timeIndices;
66 bool done;
67 };
68 std::vector<SubProduct> components_;
69 typedef std::vector<SubProduct>::iterator iterator;
70 typedef std::vector<SubProduct>::const_iterator const_iterator;
71 // common evolution data
72 std::vector<Time> rateTimes_;
73 std::vector<Time> evolutionTimes_;
75 // working variables
76 bool finalized_ = false;
78 std::vector<Time> cashflowTimes_;
79 std::vector<std::vector<Time> > allEvolutionTimes_;
80 std::vector<std::valarray<bool> > isInSubset_;
81 };
82
83}
84
85
86#endif
cloning proxy to an underlying object
Definition: clone.hpp:40
Market-model evolution description.
Composition of two or more market-model products.
std::vector< Size > suggestedNumeraires() const override
std::vector< std::valarray< bool > > isInSubset_
std::vector< std::vector< Time > > allEvolutionTimes_
std::vector< Time > cashflowTimes_
std::vector< Time > possibleCashFlowTimes() const override
const EvolutionDescription & evolution() const override
std::vector< SubProduct >::iterator iterator
const MarketModelMultiProduct & item(Size i) const
std::vector< SubProduct >::const_iterator const_iterator
void add(const Clone< MarketModelMultiProduct > &, Real multiplier=1.0)
void subtract(const Clone< MarketModelMultiProduct > &, Real multiplier=1.0)
std::vector< SubProduct > components_
void reset() override
during simulation put product at start of path
std::vector< Time > evolutionTimes_
cloning proxy to an underlying object
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
std::vector< std::vector< CashFlow > > cashflows
Clone< MarketModelMultiProduct > product