QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
compositeinstrument.hpp
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
24#ifndef quantlib_composite_instrument_hpp
25#define quantlib_composite_instrument_hpp
26
27#include <ql/instrument.hpp>
28#include <list>
29#include <utility>
30
31namespace QuantLib {
32
34
45 typedef std::pair<ext::shared_ptr<Instrument>, Real> component;
46 typedef std::list<component>::iterator iterator;
47 typedef std::list<component>::const_iterator const_iterator;
48 public:
50 void add(const ext::shared_ptr<Instrument>& instrument,
51 Real multiplier = 1.0);
53 void subtract(const ext::shared_ptr<Instrument>& instrument,
54 Real multiplier = 1.0);
56
57 void deepUpdate() override;
59
61 bool isExpired() const override;
62
63 protected:
64 void performCalculations() const override;
66 private:
67 std::list<component> components_;
68 };
69
70}
71
72#endif
std::pair< ext::shared_ptr< Instrument >, Real > component
void performCalculations() const override
void add(const ext::shared_ptr< Instrument > &instrument, Real multiplier=1.0)
adds an instrument to the composite
bool isExpired() const override
returns whether the instrument might have value greater than zero.
std::list< component >::iterator iterator
std::list< component >::const_iterator const_iterator
void subtract(const ext::shared_ptr< Instrument > &instrument, Real multiplier=1.0)
shorts an instrument from the composite
std::list< component > components_
Abstract instrument class.
Definition: instrument.hpp:44
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35